TQuery Object, RequestLive true causes 'missing right quote' exception - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

mtronixmtronix Posts: 10Member
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

  • mtronixmtronix Posts: 10Member
    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.
    :

  • TaylorQiTaylorQi Posts: 3Member
    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.
    : :
    :
    :
  • InOut.NETInOut.NET Posts: 6Member
    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.
    :

  • InOut.NETInOut.NET Posts: 6Member
    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.
    : :
    :
    :

  • mtronixmtronix Posts: 10Member
    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.