Connecting Tech Pros Worldwide Forums | Help | Site Map

Insert statement into Access 2000 DB from VB6/ADO

Paul BJ
Guest
 
Posts: n/a
#1: Nov 13 '05
I am trying to insert into a table in an Access 2000 DB from a VB6 app using
ADO 2.7.

I would have thought this should have been really easy but I cannot get it
working and I cannot see why. It is years and years since I did anything
with Access so I am wondering what I have forgotten...

I am sending a SQL string as follows directly from a connection object using
Connection.Execute(strSQL)
and I get an incorrect synatax error.

according to the debugger, I am sending this:

Insert into tbl_MCH_TIS
(Fund_Name, Fund_Class, TIS, Fund_Date)
Values("AA01", "A1", 0.88989, "06/27/2005");

but I also modified the code to send

Insert into tbl_MCH_TIS
(Fund_Name, Fund_Class, TIS, Fund_Date)
Values("AA01", "A1", 0.88989, #06/27/2005#);

and I tried

Insert into tbl_MCH_TIS
(Fund_Name, Fund_Class)
Values("AA01", "A1");

always the same result...a Syntax Error in SQL statement

Can anyone out there put me out of my misery...what is the correct syntax?

TIA

Paul BJ




Douglas J. Steele
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Insert statement into Access 2000 DB from VB6/ADO


The syntax looks okay. You sure you haven't mistyped a field name?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Paul BJ" <paul@spamlessbrownjohn.co.uk> wrote in message
news:42bb268a@news.vo.lu...[color=blue]
>I am trying to insert into a table in an Access 2000 DB from a VB6 app
>using
> ADO 2.7.
>
> I would have thought this should have been really easy but I cannot get it
> working and I cannot see why. It is years and years since I did anything
> with Access so I am wondering what I have forgotten...
>
> I am sending a SQL string as follows directly from a connection object
> using
> Connection.Execute(strSQL)
> and I get an incorrect synatax error.
>
> according to the debugger, I am sending this:
>
> Insert into tbl_MCH_TIS
> (Fund_Name, Fund_Class, TIS, Fund_Date)
> Values("AA01", "A1", 0.88989, "06/27/2005");
>
> but I also modified the code to send
>
> Insert into tbl_MCH_TIS
> (Fund_Name, Fund_Class, TIS, Fund_Date)
> Values("AA01", "A1", 0.88989, #06/27/2005#);
>
> and I tried
>
> Insert into tbl_MCH_TIS
> (Fund_Name, Fund_Class)
> Values("AA01", "A1");
>
> always the same result...a Syntax Error in SQL statement
>
> Can anyone out there put me out of my misery...what is the correct syntax?
>
> TIA
>
> Paul BJ
>
>
>[/color]


Closed Thread