Hello everybody,
I am facing a problem in inserting record in Access database. Here is the short code snippet, which gives exception "Syntax error in INSERT INTO statement", however if I print the query by uncommenting the Response.Write line and copy the query and paste it in access and run, it runs well.
VB Code:
' Insert Set Rs = Conn.Execute("SELECT [User].[UserName] FROM [User] WHERE [User].[UserName] = '" & UserName & "' AND [User].[IsDeleted] = False") If Rs.EOF Then Dim InsertSql InsertSql = "INSERT INTO [User] (Name,UserName,Password,IsAdmin,IsSupervisor,IsDeleted) VALUES('" & FullName & "','" & UserName & "','" & Password & "'," & IsAdmin & "," & IsSupervisor & ",False)" 'Response.Write(InsertSql) 'Response.End Cmd.ActiveConnection = Conn Cmd.CommandText = InsertSql Cmd.Execute() 'Set Rs = Conn.Execute(InsertSql) Response.Redirect("User.asp?Message=UserAdded") Else Response.Redirect("User.asp?Message=UserFound") End If




Reply With Quote