使用mysql更新
Dim OfficerCreated, OfficerID As String
Dim OfficerTodaysDateandTime As Date
OfficerTodaysDateandTime = Now
OfficerID = lvOfficerGrid.SelectedItems.Item(0).SubItems(0).Text
OfficerCreated = lvOfficerGrid.SelectedItems.Item(0).SubItems(5).Text
UpdateOfficer = "UPDATE pcms.users SET user_fname = '" & Me.txtOfficerFname.Text.ToUpper & "', user_mname = '" & Me.txtOfficerMname.Text.ToUpper & "'," & _
"user_lname = '" & Me.txtOfficerLname.Text.ToString & "',user_status = '" & Me.AccountStatus.ToString & "',user_created = '" & OfficerCreated & "',user_updated = '" & OfficerTodaysDateandTime & "' WHERE user_id = " & _
"'" & OfficerID & "'"
OfficerID是一个Integer值,加载在listview column1
中OfficerCreated是DATETIME,它载入listview column5
OfficerTodaysDateandTime是DATETIME
我在更新时遇到错误.. 我的代码有什么不对吗?
答案 0 :(得分:0)
UPDATE table_name SET column1 = value1, column2 = value2
WHERE [where you want to make changes]
更新各个列字段使用逗号分隔,而不是&符号。
并且还建议放置一个where子句,否则每一行都会受到更新的影响。