0

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

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by hielo
0

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?

0
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.

0

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'

0
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

0

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 & "'"

Edited by hielo: typo's found

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.