Syntax error in UPDATE statement

While I was working with Visual Basic .NET by adding a form to manage user account in my system I found an error called “Syntax error in UPDATE statement”. After figuring out what’s the cause of this error I found out that it was the name of the field that is causing the problem.

In my Users table I have the following fields:

UserID
Password
CompleteName

As you can see all of these fields are valid. The statement to save a record back to its database is:

Dim dt As DataTable = dsUsers.Tables("Users") If State = FormState.adStateAddMode Then ' add a row Dim newRow As DataRow newRow = dt.NewRow() dt.Rows.Add(newRow) End If With dt .Rows(0)("UserID") = txtUsername.Text .Rows(0)("Password") = txtPassword.Text .Rows(0)("CompleteName") = txtCompleteName.Text .Rows(0)("Admin") = changeYNValue(CStr(Check1.CheckState)) daUsers.Update(dsUsers, "Users") End With

But when I run the program and update the record, visual basic breaks at this line:

Rows(0)("Password") = txtPassword.Text

Now, looking back at what I have learned about naming convention I come to think that Password attribute is a reserved word. After changing the name of this attribute from Password to Passworda the error has gone.

This is sometimes very frustrating when you are in a hurry working with your code to meet the deadline. But this is a fact that we have to face to become a successful programmer.

The only ingredient that you need to develop is patience.

Comments

Submitted bylpayariraon Tue, 10/06/2009 - 21:03

I have managed to download a point of sale system installation file but where do i get the database password because i am failing to access the database.Can anyone tell me what program was used to code the POS system?Is it Visual Basic or VB.Net Please help
Submitted byAnonymous (not verified)on Sat, 12/25/2010 - 15:00

I already had this problem with the word "user". and now the "password" Thanks
Submitted bykyfira27 (not verified)on Sun, 04/01/2012 - 20:35

l already have problem with the line of da.update(ds." ") why it happen??? i need the solution to repair my system

Add new comment