0
我在更新時遇到錯誤。我只是這個代碼的新手。我真的很感激任何幫助。更新語句中的語法錯誤vb.net
Private Sub Save_Record()
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim sSQL As String = "SELECT * FROM Instructor"
Try
'get connection string declared in the Module1.vb and assing it to conn variable
conn = New OleDbConnection(Get_Constring)
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
'I just use the textbox tag property to idetify if the data is new or existing.
sSQL = "UPDATE Instructor set fname = ?, lname =?, mname =? , [password] = ?, [level]=?, where Username = ?"
cmd.CommandText = sSQL
cmd.Parameters.AddWithValue("@p1", txtfname.Text)
cmd.Parameters.AddWithValue("@p2", txtlname.Text)
cmd.Parameters.AddWithValue("@p3", txtinitial.Text)
cmd.Parameters.AddWithValue("@p4", txtpass.Text)
cmd.Parameters.AddWithValue("@p5", lbllevel.Text)
cmd.Parameters.AddWithValue("@p6", txtusername.Text)
cmd.ExecuteNonQuery()
MsgBox("Data has been save.")
Catch ex As Exception
MsgBox(ErrorToString)
Finally
conn.Close()
End Try
End Sub
你得到的錯誤信息是什麼? – bansi
更新語句中的語法錯誤 – user2715202