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:

  1.         Dim dt As DataTable = dsUsers.Tables("Users")
  2.  
  3.         If State = FormState.adStateAddMode Then
  4.             ' add a row
  5.             Dim newRow As DataRow
  6.  
  7.             newRow = dt.NewRow()
  8.  
  9.             dt.Rows.Add(newRow)
  10.         End If
  11.  
  12.         With dt
  13.             .Rows(0)("UserID") = txtUsername.Text
  14.             .Rows(0)("Password") = txtPassword.Text
  15.             .Rows(0)("CompleteName") = txtCompleteName.Text
  16.             .Rows(0)("Admin") = changeYNValue(CStr(Check1.CheckState))
  17.  
  18.             daUsers.Update(dsUsers, "Users")
  19.         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

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

I already had this problem with the word "user". and now the "password" Thanks

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