Currently using ASP.net 2005
I am havin an errot in update statement my code is:
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand

Dim ssql As String = "UPDATE passwrd SET password ='" + TextBox1.Text + "'where username='" + TextBox2.Text + "'"

myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _
& "Data Source=" & Server.MapPath("App_Data\pass.mdb") & ";")
MsgBox(ssql)
myCommand = New OleDb.OleDbCommand(ssql, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()

Its showing syntax error in UPDATE satement

Recommended Answers

You are having

MsgBox(ssql)

Can you seen that query and run directly? Or through debugger, set a break point and get value of ssql and post it?

Do you have single quotes as part of data? Does it always fail? Id passwrd a valid table, and other 2 columns …

Jump to Post

On your original post you are infact missing a space to the left of the WHERE keyword. My suggestions would be to use "&" instead of "+" symbol to concatenate the strings and enclose the table/fieldnames in brackets.

On another note, with regards to:

UPDATE passwrd
Jump to Post

All 7 Replies

You are having

MsgBox(ssql)

Can you seen that query and run directly? Or through debugger, set a break point and get value of ssql and post it?

Do you have single quotes as part of data? Does it always fail? Id passwrd a valid table, and other 2 columns Ok?

Dim ssql As String = "UPDATE passwrd SET password ='" + TextBox1.Text + "'where username='" + TextBox2.Text + "'"

an error here is near the where clause. Try inserting a space between ' and where.

You are having Can you seen that query and run directly? Or through debugger, set a break point and get value of ssql and post it?

Do you have single quotes as part of data? Does it always fail? Id passwrd a valid table, and other 2 columns Ok?

The update query in ssql variable is ---- UPDATE passwrd set password='1' where username='jay'

Dim ssql As String = "UPDATE passwrd SET password ='" + TextBox1.Text + "'where username='" + TextBox2.Text + "'"

an error here is near the where clause. Try inserting a space between ' and where.

frnd i did try adding space but nothing happen

On your original post you are infact missing a space to the left of the WHERE keyword. My suggestions would be to use "&" instead of "+" symbol to concatenate the strings and enclose the table/fieldnames in brackets.

On another note, with regards to:

UPDATE passwrd

Are you sure your TABLE is named passwrd? To clarify, if you had the following:
Table: Person
Fields: password, username

then it should be:

Dim ssql As String = "UPDATE [Person] SET [password] ='" & TextBox1.Text & "' WHERE [username]='" & TextBox2.Text & "'"

Thnqs frnd problem solved..........
Need to use [] brackets

You are welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.