
December 12th, 2012, 06:29 PM
|
|
Registered User
|
|
Join Date: Mar 2012
Posts: 15
Time spent in forums: 7 h 59 m 23 sec
Reputation Power: 0
|
|
|
Problem with parameterized update query
I am trying to update a database entry using a parameterized query, but for some reason it doesnt seem to want to work. The update statement works without the parameters there, but with them nothing happens. No errors, no crashes, and no update either.
This is the code i use:
Code:
sqlString = "UPDATE table SET field1 = @value1, field2 = @value2, field3 = @value3 WHERE field1 = @currentValue"
dbCommand.CommandText = sqlString
dbCommand.Parameters.AddWithValue("@value1", txtOne.Text)
dbCommand.Parameters.AddWithValue("@field2 ", txtTwo.Text)
dbCommand.Parameters.AddWithValue("@field3 ", txtThree.Text)
dbCommand.Parameters.AddWithValue("@currentValue", lstListBox.SelectedValue)
dbCommand.ExecuteNonQuery()
Can anyone tell me what i am doing wrong with the code?
|