Hi there
Im programming using a SQL update statement in vb.net and I keep getting a syntax error in UPDATE statement
I haven't got that much experience with SQL and I cant seem to spot the problem
Im using the oledb connection to connect to a access database
Heres the code:
Anyone spot the problem?
Cheers
Im programming using a SQL update statement in vb.net and I keep getting a syntax error in UPDATE statement
I haven't got that much experience with SQL and I cant seem to spot the problem
Im using the oledb connection to connect to a access database
Heres the code:
VB.NET:
Private Sub adminuserchangename_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles adminuserchangename.Click
Dim getrecord As Integer = adminuserlist.SelectedIndex
Dim newname As String
Do
newname = InputBox("What would you like the new name to be")
If newname = "" Then
MsgBox("Invalid entry please try again")
End If
Loop Until newname > ""
Dim objcommand As New OleDbCommand("UPDATE tblusers SET User=? WHERE ID=?", Conn)
objcommand.Parameters.AddWithValue("@User", newname)
objcommand.Parameters.AddWithValue("@ID", getrecord + 1)
Conn.Open()
Try
objcommand.ExecuteNonQuery()
Catch SQLError As OleDb.OleDbException
MessageBox.Show(SQLError.Message)
End Try
Conn.Close()
objcommand.Parameters.Clear()
FillDataSetAndViewusers()
adminuserlist.Items(getrecord) = newname
End Sub
Anyone spot the problem?
Cheers