Data saved in database through oledbcommand problem

vks.gautam1

Well-known member
Joined
Oct 10, 2008
Messages
78
Location
Chandigarh, India
Programming Experience
Beginner
VB.NET:
 cmd = New OleDbCommand("insert into userinfo(FirstName,LastName,UserName,Password,SequrityQuestion,Answer,Address) values(@FirstName,@LastName,@username,@password,@SequrityQuestion,@Answer,@Address)", cn)
            With cmd.Parameters
                .Add("@FirstName", OleDbType.VarChar).Value = Me.TxtFirstName.Text
                .Add("@LastName", OleDbType.VarChar).Value = Me.TxtLastName.Text
                .Add("@UserName", OleDbType.VarChar).Value = Me.TxtUserName.Text
                .Add("@Password", OleDbType.VarChar).Value = Me.TxtPassword.Text
                .Add("@SequrityQuestion", OleDbType.VarChar).Value = Me.DDLSequirityQuestion.SelectedItem.Text
                .Add("@Answer", OleDbType.VarChar).Value = Me.TxtAnswer.Text
                .Add("@Address", OleDbType.VarChar).Value = Me.TxtAddress.Text
            End With
            cmd.ExecuteNonQuery()
            MsgBox("Data Updated")

Error-Syntax Error INSERT Statement. Field name in insert query is correct.
 
If you have table names that is same as reserved db words you have to espace them like this: [specialname]
VS data access wizards escapes all table names like this.
 
Userinfo =Table Name
i used select command
VB.NET:
cmd = New OleDbCommand("select username,password from userinfo where username=@username and password=@password", cn)
in the other Page.. It works. I do not know which is reserved word in Insert query.

This all is in ASP.NET
 
Column names, too, VS escapes everything.
 
Back
Top