Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I program a little website using access as a database system and ASP.NET VB as a programming language.
My problem is when executing Insert function which insert a new user into access file an error occurred which telling me that INSERT INTO statement is invalid when executing ExecuteNonQuery().

this is the code please tell me if the statement is wrong and what is the correct because I'm quit sure that it's correct:

VB
Connection.Open()
Dim SQL As String = String.Format("INSERT INTO Users(UserName,password,Authonticaion) VALUES('{0}','{1}','{2}')", UserName, password, Authontication)
Command.CommandText = SQL
Command.CommandType = CommandType.Text
Command.Connection = Connection
Command.ExecuteNonQuery()
Connection.Close()


Note: This website for my friend and my friend want this website works only on access file. So, I can't use another database system.
Posted
Comments
Maciej Los 17-Mar-13 15:08pm    
What's not working?
What kind of error?
[no name] 17-Mar-13 17:14pm    
try [password] as your column name. I believe, but not sure, that password is reserved in access.
Mike Meinz 17-Mar-13 18:02pm    
When there is more than couple of simultaneous users, Microsoft Access is a poor choice for a web site DBMS. SQL SERVER EXPRESS would be a far better choice.
[no name] 17-Mar-13 20:12pm    
And add a space between "Users" and "(" and "VALUES" and the "("
[no name] 17-Mar-13 23:29pm    
The error occurred again. I have checked all columns and spaces and spelling all that is fine. But why VS tells me "Syntax error in INSERT INTO statement.".??????????
DAMN IT

1 solution

Hmm, so you have MS Access installed on your server?
If the former is true then please do tell us what exception is being raised and have you tried the constructed SQL in a query?

Regards,
— Manfred
 
Share this answer
 
Comments
[no name] 17-Mar-13 15:17pm    
This is the error exception: "Syntax error in INSERT INTO statement."
Maciej Los 17-Mar-13 16:18pm    
Check what is in UserName, password, Authontication variables.
Maciej Los 17-Mar-13 17:05pm    
As you see, i have used "Reply" to OP comment. So, i'm asking OP ;)
Manfred Rudolf Bihy 17-Mar-13 17:05pm    
My bad :)
Mike Meinz 17-Mar-13 17:58pm    
You have Authentication spelled wrong. Could that be the issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900