Board index » delphi » SQL problem with ADO & MS Access DB

SQL problem with ADO & MS Access DB

Hi,

[Windows NT 4.0, Delphi 5 SP1, ADO, Access 97]

I am having a problem using the SQL property in the ADOQuery control.
The SQL string is:
SELECT * FROM CustFile

As soon as I set the Active property to true, I receive the following
error:
"Syntax error in FROM clause."

What am I doing wrong?

Thanks for your help,
Bill Greening

 

Re:SQL problem with ADO & MS Access DB


Bill,

When using SQL, you must include the database name infront of the table name
Example:
Select * from Mydb.ClientTbl

This should work.

Jim Reznikoff

Quote
"Bill Greening" <w...@daico.com> wrote in message

news:39e700f5.2982308@newsgroups.borland.com...
Quote
> Hi,

> [Windows NT 4.0, Delphi 5 SP1, ADO, Access 97]

> I am having a problem using the SQL property in the ADOQuery control.
> The SQL string is:
> SELECT * FROM CustFile

> As soon as I set the Active property to true, I receive the following
> error:
> "Syntax error in FROM clause."

> What am I doing wrong?

> Thanks for your help,
> Bill Greening

Re:SQL problem with ADO & MS Access DB


Quote
"Bill Greening" <w...@daico.com> wrote in message

news:39e700f5.2982308@newsgroups.borland.com...

Quote
> I am having a problem using the SQL property in the ADOQuery control.
> The SQL string is:
> SELECT * FROM CustFile

One is you are still using Access97.  It creates more trouble than you can
imagine with ADO.  But try:

Seclect *
  From CustFile
Putting things like "From", "Where", "OrderBy" on seperate lines seems to
fix this problem.  If you use Access to create your querys for you you
should have no more problems.  At least Access knows that you need to put
every thing on it's own line.

Bob

Re:SQL problem with ADO & MS Access DB


Jim,

Thanks for your help.  Looks like adding the database name fixed my
problem. I am still having problems with query statements.  Where may
find a tutorial regarding query statements used with Delphi 5 and Ado
Express?

Thanks,
Bill Greening

Quote
"Jim Reznikoff" <ms...@erols.com> wrote:
>Bill,

>When using SQL, you must include the database name infront of the table name
>Example:
>Select * from Mydb.ClientTbl

>This should work.

>Jim Reznikoff
>"Bill Greening" <w...@daico.com> wrote in message
>news:39e700f5.2982308@newsgroups.borland.com...
>> Hi,

>> [Windows NT 4.0, Delphi 5 SP1, ADO, Access 97]

>> I am having a problem using the SQL property in the ADOQuery control.
>> The SQL string is:
>> SELECT * FROM CustFile

>> As soon as I set the Active property to true, I receive the following
>> error:
>> "Syntax error in FROM clause."

>> What am I doing wrong?

>> Thanks for your help,
>> Bill Greening

Re:SQL problem with ADO & MS Access DB


You can start here and go the the intermediate and advanced levels from
there.
http://msdn.microsoft.com/library/techart/acfundsql.htm
This only addresses Access 2000 but "A Lot" of the SQL commands are the
same.  If you migrate to A2000 you will be in heaven.

Bob

Re:SQL problem with ADO & MS Access DB


I am looking at "Fundamental Microsoft Jet SQL for Access 2000".  It
looks like a good starting place.

Thanks!
Bill Greening

Quote
"Bob Wasaff" <bwas...@suscom.net> wrote:
>You can start here and go the the intermediate and advanced levels from
>there.
>http://msdn.microsoft.com/library/techart/acfundsql.htm
>This only addresses Access 2000 but "A Lot" of the SQL commands are the
>same.  If you migrate to A2000 you will be in heaven.

>Bob

Re:SQL problem with ADO & MS Access DB


Bill, you should never ,never have to qualify a single table querry. You
have something else wrong such as your ado connection propery or your
connection string. Your not connecting to the database so the sql fails.
Quote
Bill Greening wrote in message <39e700f5.2982...@newsgroups.borland.com>...
>Hi,

>[Windows NT 4.0, Delphi 5 SP1, ADO, Access 97]

>I am having a problem using the SQL property in the ADOQuery control.
>The SQL string is:
>SELECT * FROM CustFile

>As soon as I set the Active property to true, I receive the following
>error:
>"Syntax error in FROM clause."

>What am I doing wrong?

>Thanks for your help,
>Bill Greening

Re:SQL problem with ADO & MS Access DB


You  should never need to do that (include the MDB in the sql).... the
connection must be unassigned or there must
be another problem.

Quote
> Bill,

> When using SQL, you must include the database name infront of the table
name
> Example:
> Select * from Mydb.ClientTbl

> This should work.

Re:SQL problem with ADO & MS Access DB


In the Data Link Properties dialog box and on the Connection tab,
clicking the test connection button, pops up the Microsoft Data Link
dialog box with the message "Test connection succeeded."  I seem to
have a connection to the database as the TDBEdit and TDBGrid controls
show data from the database.

Maybe there is something wrong with my connection string.  The
following is my connection string:

Provider=Microsoft.Jet.OLEDB.4.0;Password="";
User ID=Admin;Data
Source=D:\Delphi Projects\Customer Boards\Customer Data.mdb;
Mode=Share Deny None;
Extended Properties="";
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Database Password="";
Jet OLEDB:Engine Type=4;
Jet OLEDB:Database Locking Mode=0;
Jet OLEDB:Global Partial Bulk Ops=2;
Jet OLEDB:Global Bulk Transactions=1;
Jet OLEDB:New Database Password="";
Jet OLEDB:Create System Database=False;
Jet OLEDB:Encrypt Database=False;
Jet OLEDB:Don't Copy Locale on Compact=False;
Jet OLEDB:Compact Without Replica Repair=False;
Jet OLEDB:SFP=False

Bill Greeing

Quote
"Del Murray" <d...@emerald-coast.org> wrote:
>Bill, you should never ,never have to qualify a single table querry. You
>have something else wrong such as your ado connection propery or your
>connection string. Your not connecting to the database so the sql fails.

>Bill Greening wrote in message <39e700f5.2982...@newsgroups.borland.com>...
>>Hi,

>>[Windows NT 4.0, Delphi 5 SP1, ADO, Access 97]

>>I am having a problem using the SQL property in the ADOQuery control.
>>The SQL string is:
>>SELECT * FROM CustFile

>>As soon as I set the Active property to true, I receive the following
>>error:
>>"Syntax error in FROM clause."

>>What am I doing wrong?

>>Thanks for your help,
>>Bill Greening

Other Threads