C++ Builder

Moderators: Lundin
Number of threads: 509
Number of posts: 1146

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
TQuery Object, RequestLive true causes 'missing right quote' exception Posted by mtronix on 24 Sept 2007 at 8:06 AM
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.
Report
Re: TQuery Object, RequestLive true causes 'missing right quote' excep Posted by mtronix on 24 Sept 2007 at 11:16 AM
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.
:

Report
Re: TQuery Object, RequestLive true causes 'missing right quote' excep Posted by TaylorQi on 28 Sept 2007 at 1:23 AM
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.
: :
:
:
Report
Re: TQuery Object, RequestLive true causes 'missing right quote' excep Posted by InOut.NET on 4 Oct 2007 at 4:46 PM
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.
: :
:
:

Report
Re: TQuery Object, RequestLive true causes 'missing right quote' excep Posted by InOut.NET on 4 Oct 2007 at 4:42 PM
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.
:

Report
Re: TQuery Object, RequestLive true causes 'missing right quote' excep Posted by mtronix on 5 Oct 2007 at 11:45 AM
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.
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.