TQuery Object, RequestLive true causes 'missing right quote' exception

Hello,
I am working with an old legacy project that used the BDE. It has been giving me a fair amount of heartache. I was able to establish a connection to the database using an alias and by creating a system DSN....However, eventually I need to make the database DSN-less. (issue for a later post).
For now, I have "hot-wired" the database into the project and I am able to connect to the database by setting connected = true on the *.dfm . This is good. Now, I run into issues with a TQuery object.
The code runs through and connects to the database itself. Then the code attempts the following function call on the TQuery object. The first call is in one file and the definition is shown below:

BDEUtil::OpenQuery(Settings, "SELECT * FROM Settings", databaseSettings->DatabaseName);

void BDEUtil::OpenQuery(TQuery *Query, String SQL, String DatabaseName)
{
// Close existing query
CloseQuery(Query);
// Execute query
Query->DatabaseName = DatabaseName;
Query->SQL->Add (SQL); //Exception If RequestLive = True
Query->Prepare();
Query->Open();
}

The line Query->SQL->Add (SQL); crashes if RequestLive = true (which is what I need it to be because I have to edit this database). The exception thrown is:

"raised exception class EDBEngineError with message 'Missing right quote.'.

However, if I set this to false, the code runs fine...only to complain later about not being able to edit the database on a ->Edit(); call on the TQuery object. Anyone have any idea what the issue would be?

Thank you.

Comments

  • Hello,
    I have been working at this problem for sometime and here is the heartache. The customer has a database with a field called Manufacturer's name. If I take out the ' the code will execute. Does anyone know how I can leave the ' in the field?

    Thanks,
    ~Mark

    : Hello,
    : I am working with an old legacy project that used the BDE. It
    : has been giving me a fair amount of heartache. I was able to
    : establish a connection to the database using an alias and by
    : creating a system DSN....However, eventually I need to make the
    : database DSN-less. (issue for a later post).
    : For now, I have "hot-wired" the database into the project and I
    : am able to connect to the database by setting connected = true on
    : the *.dfm . This is good. Now, I run into issues with a TQuery
    : object.
    : The code runs through and connects to the database itself.
    : Then the code attempts the following function call on the TQuery
    : object. The first call is in one file and the definition is shown
    : below:
    :
    : BDEUtil::OpenQuery(Settings, "SELECT * FROM Settings",
    : databaseSettings->DatabaseName);
    :
    : void BDEUtil::OpenQuery(TQuery *Query, String SQL, String
    : DatabaseName)
    : {
    : // Close existing query
    : CloseQuery(Query);
    : // Execute query
    : Query->DatabaseName = DatabaseName;
    : Query->SQL->Add (SQL); //Exception If RequestLive
    : = True
    : Query->Prepare();
    : Query->Open();
    : }
    :
    : The line Query->SQL->Add (SQL); crashes if RequestLive = true (which
    : is what I need it to be because I have to edit this database). The
    : exception thrown is:
    :
    : "raised exception class EDBEngineError with message 'Missing right
    : quote.'.
    :
    : However, if I set this to false, the code runs fine...only to
    : complain later about not being able to edit the database on a
    : ->Edit(); call on the TQuery object. Anyone have any idea what the
    : issue would be?
    :
    : Thank you.
    :

  • Hello,
    Use '' to replace ' in SQL.
    Taylor
    : Hello,
    : I have been working at this problem for sometime and here is the
    : heartache. The customer has a database with a field called
    : Manufacturer's name. If I take out the ' the code will execute.
    : Does anyone know how I can leave the ' in the field?
    :
    : Thanks,
    : ~Mark
    :
    : : Hello,
    : : I am working with an old legacy project that used the BDE. It
    : : has been giving me a fair amount of heartache. I was able to
    : : establish a connection to the database using an alias and by
    : : creating a system DSN....However, eventually I need to make the
    : : database DSN-less. (issue for a later post).
    : : For now, I have "hot-wired" the database into the project and I
    : : am able to connect to the database by setting connected = true on
    : : the *.dfm . This is good. Now, I run into issues with a TQuery
    : : object.
    : : The code runs through and connects to the database itself.
    : : Then the code attempts the following function call on the TQuery
    : : object. The first call is in one file and the definition is shown
    : : below:
    : :
    : : BDEUtil::OpenQuery(Settings, "SELECT * FROM Settings",
    : : databaseSettings->DatabaseName);
    : :
    : : void BDEUtil::OpenQuery(TQuery *Query, String SQL, String
    : : DatabaseName)
    : : {
    : : // Close existing query
    : : CloseQuery(Query);
    : : // Execute query
    : : Query->DatabaseName = DatabaseName;
    : : Query->SQL->Add (SQL); //Exception If RequestLive
    : : = True
    : : Query->Prepare();
    : : Query->Open();
    : : }
    : :
    : : The line Query->SQL->Add (SQL); crashes if RequestLive = true (which
    : : is what I need it to be because I have to edit this database). The
    : : exception thrown is:
    : :
    : : "raised exception class EDBEngineError with message 'Missing right
    : : quote.'.
    : :
    : : However, if I set this to false, the code runs fine...only to
    : : complain later about not being able to edit the database on a
    : : ->Edit(); call on the TQuery object. Anyone have any idea what the
    : : issue would be?
    : :
    : : Thank you.
    : :
    :
    :
  • All looks fine.

    I'd say its something else - something stupid like the Settings table are open some where else. Or a read-only flag. Or the DNS Setup prohibits Request Live on SQL.

    Why not use TTable?


    : Hello,
    : I am working with an old legacy project that used the BDE. It
    : has been giving me a fair amount of heartache. I was able to
    : establish a connection to the database using an alias and by
    : creating a system DSN....However, eventually I need to make the
    : database DSN-less. (issue for a later post).
    : For now, I have "hot-wired" the database into the project and I
    : am able to connect to the database by setting connected = true on
    : the *.dfm . This is good. Now, I run into issues with a TQuery
    : object.
    : The code runs through and connects to the database itself.
    : Then the code attempts the following function call on the TQuery
    : object. The first call is in one file and the definition is shown
    : below:
    :
    : BDEUtil::OpenQuery(Settings, "SELECT * FROM Settings",
    : databaseSettings->DatabaseName);
    :
    : void BDEUtil::OpenQuery(TQuery *Query, String SQL, String
    : DatabaseName)
    : {
    : // Close existing query
    : CloseQuery(Query);
    : // Execute query
    : Query->DatabaseName = DatabaseName;
    : Query->SQL->Add (SQL); //Exception If RequestLive
    : = True
    : Query->Prepare();
    : Query->Open();
    : }
    :
    : The line Query->SQL->Add (SQL); crashes if RequestLive = true (which
    : is what I need it to be because I have to edit this database). The
    : exception thrown is:
    :
    : "raised exception class EDBEngineError with message 'Missing right
    : quote.'.
    :
    : However, if I set this to false, the code runs fine...only to
    : complain later about not being able to edit the database on a
    : ->Edit(); call on the TQuery object. Anyone have any idea what the
    : issue would be?
    :
    : Thank you.
    :

  • I see in your other post that you use Builder 3 - and you're using todays version of Access ODBC Drivers?

    Possiblity for incompatible ODBC Driver for TQuery?

    : Hello,
    : I have been working at this problem for sometime and here is the
    : heartache. The customer has a database with a field called
    : Manufacturer's name. If I take out the ' the code will execute.
    : Does anyone know how I can leave the ' in the field?
    :
    : Thanks,
    : ~Mark
    :
    : : Hello,
    : : I am working with an old legacy project that used the BDE. It
    : : has been giving me a fair amount of heartache. I was able to
    : : establish a connection to the database using an alias and by
    : : creating a system DSN....However, eventually I need to make the
    : : database DSN-less. (issue for a later post).
    : : For now, I have "hot-wired" the database into the project and I
    : : am able to connect to the database by setting connected = true on
    : : the *.dfm . This is good. Now, I run into issues with a TQuery
    : : object.
    : : The code runs through and connects to the database itself.
    : : Then the code attempts the following function call on the TQuery
    : : object. The first call is in one file and the definition is shown
    : : below:
    : :
    : : BDEUtil::OpenQuery(Settings, "SELECT * FROM Settings",
    : : databaseSettings->DatabaseName);
    : :
    : : void BDEUtil::OpenQuery(TQuery *Query, String SQL, String
    : : DatabaseName)
    : : {
    : : // Close existing query
    : : CloseQuery(Query);
    : : // Execute query
    : : Query->DatabaseName = DatabaseName;
    : : Query->SQL->Add (SQL); //Exception If RequestLive
    : : = True
    : : Query->Prepare();
    : : Query->Open();
    : : }
    : :
    : : The line Query->SQL->Add (SQL); crashes if RequestLive = true (which
    : : is what I need it to be because I have to edit this database). The
    : : exception thrown is:
    : :
    : : "raised exception class EDBEngineError with message 'Missing right
    : : quote.'.
    : :
    : : However, if I set this to false, the code runs fine...only to
    : : complain later about not being able to edit the database on a
    : : ->Edit(); call on the TQuery object. Anyone have any idea what the
    : : issue would be?
    : :
    : : Thank you.
    : :
    :
    :

  • Hello,
    It is something stupid with the BDE. I had to remove an apostrophe from one of the field names to get it to work. Apparently, BDE has issues with SQL statements that contain any spaces / or ' in it. Probably wasn't that way in the past. Codegear support was definitley pushing that I switch to ADO which is what I will attempt now.


    : Hello,
    : I am working with an old legacy project that used the BDE. It
    : has been giving me a fair amount of heartache. I was able to
    : establish a connection to the database using an alias and by
    : creating a system DSN....However, eventually I need to make the
    : database DSN-less. (issue for a later post).
    : For now, I have "hot-wired" the database into the project and I
    : am able to connect to the database by setting connected = true on
    : the *.dfm . This is good. Now, I run into issues with a TQuery
    : object.
    : The code runs through and connects to the database itself.
    : Then the code attempts the following function call on the TQuery
    : object. The first call is in one file and the definition is shown
    : below:
    :
    : BDEUtil::OpenQuery(Settings, "SELECT * FROM Settings",
    : databaseSettings->DatabaseName);
    :
    : void BDEUtil::OpenQuery(TQuery *Query, String SQL, String
    : DatabaseName)
    : {
    : // Close existing query
    : CloseQuery(Query);
    : // Execute query
    : Query->DatabaseName = DatabaseName;
    : Query->SQL->Add (SQL); //Exception If RequestLive
    : = True
    : Query->Prepare();
    : Query->Open();
    : }
    :
    : The line Query->SQL->Add (SQL); crashes if RequestLive = true (which
    : is what I need it to be because I have to edit this database). The
    : exception thrown is:
    :
    : "raised exception class EDBEngineError with message 'Missing right
    : quote.'.
    :
    : However, if I set this to false, the code runs fine...only to
    : complain later about not being able to edit the database on a
    : ->Edit(); call on the TQuery object. Anyone have any idea what the
    : issue would be?
    :
    : Thank you.
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories