INSERT command with Access

J

John Straumann

Hi all:

I am trying to update an Access table from an ASP.NET page and am getting a
"syntax error" statement back, but I can't for the life of me see what is
wrong with the string shown below. All the data items in Access are set to
Text.

INSERT INTO test( t1, t2, t3, t4, t5 ) VALUES( 'test1', 'test2', 'test3',
'test4', 'test5')

Any ideas?

Thanks.


John [MSFT].

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

John Straumann

I tried that...no joy :(

John [MSFT].

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Sylvain Lafontaine

Maybe it's something else than a true "syntax error"; for example you have a
problem with the connection string or one of the name t1, ... is mispelled
(ie. not the same name in the underlying table).

You must also make sure that the account '<machinename = your
computername>\ASPNET' has the proper rights to write to the mdb file.

Finally, if you have used something else than t1, ..., t5; then make that
none of these names are a reserved word.
 
S

Sylvain Lafontaine

Maybe double quotes " must be used instead of single quote ' for delimiting
the string constants?

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


Sylvain Lafontaine said:
Maybe it's something else than a true "syntax error"; for example you have
a problem with the connection string or one of the name t1, ... is
mispelled (ie. not the same name in the underlying table).

You must also make sure that the account '<machinename = your
computername>\ASPNET' has the proper rights to write to the mdb file.

Finally, if you have used something else than t1, ..., t5; then make that
none of these names are a reserved word.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


John Straumann cogeco.ca> said:
Hi all:

I am trying to update an Access table from an ASP.NET page and am getting
a "syntax error" statement back, but I can't for the life of me see what
is wrong with the string shown below. All the data items in Access are
set to Text.

INSERT INTO test( t1, t2, t3, t4, t5 ) VALUES( 'test1', 'test2', 'test3',
'test4', 'test5')

Any ideas?

Thanks.


John [MSFT].

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
B

Bob Powell [MVP]

I'd be inclined to go with...
"INSERT INTO test(t1, t2, t3, t4) VALUES(?,?,?,?);"

and then add parameters to the command with the names "t1" "t2" in order
etc...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
J

John Straumann

Hey all:

Thanks for the responses. Apparently the name of one of my columns, "time"
is a reserved word, I changed it and it works...

John.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top