Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Inserting into an Access database


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Mar 20, 2017 11:22 AM Last Post By: Barry Wood
Barry Wood

Posts: 73
Registered: 9/3/01
Inserting into an Access database  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 8:29 AM
Hi,

I have the following code:

dm.fdqMatchPlayers.SQL.Text:= 'INSERT INTO VetsMatchPlayers( MatchDate, Match, Player ) VALUES( :MD, :MA, :PL )';
dm.fdqMatchPlayers.ParamByName('MD').AsDateTime:= dDate;
dm.fdqMatchPlayers.ParamByName('MA').AsString := cMatch;
dm.fdqMatchPlayers.ParamByName('PL').AsString := cPlayer;
dm.fdqMatchPlayers.ExecSQL;

which, when run, gives an error message: Syntax error in INSERT TO statement.

I've used similar code before without error (but not for an Access database). Does Access need a different format or way to insert with parameters?
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Inserting into an Access database  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 10:15 AM   in response to: Barry Wood in response to: Barry Wood
dm.fdqMatchPlayers.SQL.Text:= 'INSERT INTO VetsMatchPlayers( MatchDate, Match, Player ) VALUES( :MD, :MA, :PL )';
...
which, when run, gives an error message: Syntax error in INSERT TO statement.

INTO or TO ?

--
With best regards,
Dmitry
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Inserting into an Access database  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 12:14 PM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry,

Well, a normal INSERT command takes the form INSERT INTO tableName( fields ) VALUES( values) doesn't it?

Dmitry Arefiev wrote:
dm.fdqMatchPlayers.SQL.Text:= 'INSERT INTO VetsMatchPlayers( MatchDate, Match, Player ) VALUES( :MD, :MA, :PL )';
...
which, when run, gives an error message: Syntax error in INSERT TO statement.

INTO or TO ?

--
With best regards,
Dmitry
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Inserting into an Access database  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 3:05 PM   in response to: Barry Wood in response to: Barry Wood
Dmitry,
Sorry I se what you mean - that was just me transcribing the error message incorrectly:

[FireDAC][Phys][ODBC][Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

is the full error message.

Barry Wood wrote:
Dmitry,

Well, a normal INSERT command takes the form INSERT INTO tableName( fields ) VALUES( values) doesn't it?

Dmitry Arefiev wrote:
dm.fdqMatchPlayers.SQL.Text:= 'INSERT INTO VetsMatchPlayers( MatchDate, Match, Player ) VALUES( :MD, :MA, :PL )';
...
which, when run, gives an error message: Syntax error in INSERT TO statement.

INTO or TO ?

--
With best regards,
Dmitry
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Inserting into an Access database  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2017 9:38 PM   in response to: Barry Wood in response to: Barry Wood
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Inserting into an Access database  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2017 11:22 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry,

Yes, Match is a reserved word in Access. Changed it's name and it now works a treat. Many thanks for your help.

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02