Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General SQL Error, out of memory

Status
Not open for further replies.

leit0050

Technical User
Sep 4, 2007
29
US
Hello,
My project is using the BDE (borland database engine) and when I get to the point where the database object is set

Database->Connected = true;

an exception is thrown by the debugger that states 'General SQL error. Out of Memory.'

does anyone know what this means? The alias points to the correct file and there are checks to see if the database is read/write protected.

Thanks
 
Can you show us more of the code? Also, how big is the table you are trying to read? You may be trying to copy all the data over from the table.



James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
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
 
Sorry for the delay. It's been a while since I've used BDE. There are some examples installed in the \Program Files\Borland\CBuilder6\Examples directory.

You might also want to look at thread101-843824, too.


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Hi,
Thanks for the help. Actually, what was causing the error was that I was using an old project that used driver MSACCESS. This became outdated post access 97.
The BDE is very cumbersome now when I think that it should not be. It appears to currently require you to setup a microsoft ODBC connection so you need a DSN. Based on their tech support, ADO is probably the better option to go...but they are not directly transparent.
 
Borland/Codegear has strongly suggested that BDE is on the way out. I've been using ADO for the main connection to our SQL server. It works very well.

What do you mean when you say, "they are not directly transparent?"



James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
You cannot just substitute one for the other, there is some overhead associated with the change.
 
OK.
I understand now.
:)


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top