insert statment
-
hellow to all i am trying to make insert statment into a access database .. i write the folloing statment MyOledbCommand.CommandText = "Insert Into Messages " _ & "(firstname,lastname,username,password,date) " _ & "Values (" & "'" & String2 & "', " & "'" & String3 & "', " & "'" & String4 & "', " & "'" & String5 & "')" but i keep getting the msg Syntax error insert statment .. the more odd thing is that i use the same statment in other form and it run's fine ! what could be the problem .. i had tried million thing and possibilities nothing is working :( thxx a lot
-
hellow to all i am trying to make insert statment into a access database .. i write the folloing statment MyOledbCommand.CommandText = "Insert Into Messages " _ & "(firstname,lastname,username,password,date) " _ & "Values (" & "'" & String2 & "', " & "'" & String3 & "', " & "'" & String4 & "', " & "'" & String5 & "')" but i keep getting the msg Syntax error insert statment .. the more odd thing is that i use the same statment in other form and it run's fine ! what could be the problem .. i had tried million thing and possibilities nothing is working :( thxx a lot
maybe the problem isnt with your statment, but with your connection?
-
hellow to all i am trying to make insert statment into a access database .. i write the folloing statment MyOledbCommand.CommandText = "Insert Into Messages " _ & "(firstname,lastname,username,password,date) " _ & "Values (" & "'" & String2 & "', " & "'" & String3 & "', " & "'" & String4 & "', " & "'" & String5 & "')" but i keep getting the msg Syntax error insert statment .. the more odd thing is that i use the same statment in other form and it run's fine ! what could be the problem .. i had tried million thing and possibilities nothing is working :( thxx a lot
You may wnat to check the values of each string, If one of them contains a single quote mark, then your insert statement will fail.
-
hellow to all i am trying to make insert statment into a access database .. i write the folloing statment MyOledbCommand.CommandText = "Insert Into Messages " _ & "(firstname,lastname,username,password,date) " _ & "Values (" & "'" & String2 & "', " & "'" & String3 & "', " & "'" & String4 & "', " & "'" & String5 & "')" but i keep getting the msg Syntax error insert statment .. the more odd thing is that i use the same statment in other form and it run's fine ! what could be the problem .. i had tried million thing and possibilities nothing is working :( thxx a lot
"Date" is a VB reserved word, don't take it a habit of using reserved words, however u can still use it as a DB fieldm enclose it with "[]" MyOledbCommand.CommandText = "Insert Into Messages " _ & "(firstname,lastname,username,password,[date]) " _ & "Values (" & "'" & String2 & "', " & "'" & String3 & "', " & "'" & String4 & "', " & "'" & String5 & "')" good luck ;)