Hi,
Sure, I'll also provide a little more background info. Basically, this was an old access 97 database. I now have access 2003 on my machine. I left the database alone and get this error. If I upgrade the database, I still get the same error. The database is not very large at all. It has 6 tables and the most records in any table is around 38 with about 20 fields. The remaining 5 tables have 4 records and ~10 fields.
The code makes the connection through the Tdatabase object. None of the object explorer stuff is really filled in. They set this up through code. Here are the places that setup the alias.
//****************************************************************************
// CreateAlias
//****************************************************************************
bool BDEUtil::CreateAccessAlias(String AliasName, String Path)
{
TStringList *AliasParams;
String DBPathNameValue;
// Make sure database file exists
if (access(Path.c_str(), 0)) { return false; }
// See if Alias already exists
if (AliasExists(AliasName)) { return false; }
// Form path name
DBPathNameValue = "DATABASE NAME=";
DBPathNameValue += Path;
try
{
AliasParams = new TStringList();
AliasParams->Add(DBPathNameValue);
Session->AddAlias(AliasName, "MSACCESS", AliasParams);
Session->SaveConfigFile();
}
catch(EDBEngineError &e)
{
delete AliasParams;
return false;
}
delete AliasParams;
return true;
}
Then it calls to open the connection
void BDEUtil::OpenAccessDatabase(TDatabase *Database, String AliasName,
String MdbPath, bool NeedWriteAccess,
bool SuppressLogin)
{
const String FUNCTION_NAME = "BDEUtil::OpenAccessDatabase";
// Make sure file exists
if (access(MdbPath.c_str(), 0))
{
throw VCLUtil::EExceptionExt(FUNCTION_NAME, String("Unable to open database. File ") +
MdbPath + String(" doesn't exist"), "Call to access failed.");
}
// Check write access if necessary
if (NeedWriteAccess && access(MdbPath.c_str(), 2))
{
throw VCLUtil::EExceptionExt(FUNCTION_NAME, String("Unable to open database. The file \"") +
MdbPath + String("\" is write protected."), "Call to access failed. File read-only");
}
// Do all database work in a try catch block
try
{
// Delete the existing alias if it exists and create a new one
if (AliasExists(AliasName))
{
if (!DeleteAlias(AliasName))
{
throw VCLUtil::EExceptionExt(FUNCTION_NAME, String("Unable to open "
"was an unknown problem accessing \"") + MdbPath + String("\""),
"Call to DeleteAlias failed");
}
}
if (!CreateAccessAlias(AliasName, MdbPath))
{
throw VCLUtil::EExceptionExt(FUNCTION_NAME, String("Unable to open "
"was an unknown problem accessing \"") + MdbPath + String("\""),
String("Unable to create the alias \"") + AliasName + String("\"."));
}
Database->Connected = false;
Database->AliasName = AliasName;
Database->LoginPrompt = !SuppressLogin;
Database->Connected = true;
}
catch(EDBEngineError &e)
{
throw VCLUtil::EExceptionExt(FUNCTION_NAME, String("Datbase Error: There "
"was an unknown problem accessing \"") + MdbPath + String("\""),
String("Database Error: \"") + e.Message + String("\"."));
}
}
the code crashes right after Database->Connected=true; If I hit break, it is asking for DBTables.pas which I don't know if that is a legacy issue related to this or not.
The one thing I was wondering is that it sets up the alias to a type MSACCESS. I don't know if this is the correct parameter any more. Any suggestions? Do you know anywhere I can look that has the most basic of basic examples on how to use BDE to connect to an access database?
Thank you