我搞错了
标准表达式vb.net编辑按钮中的数据类型不匹配
单击vb2010项目上的“编辑”按钮时。添加和搜索按钮工作良好,但不对编辑按钮。这是我的代码:
Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=D:\pcInventory.accdb"
myConnection = New OleDbConnection
OpenStr = "Has Open Office"
If TbPCnum.Text = "" Then
MsgBox("Please select data.")
Else
myConnection.ConnectionString = connString
myConnection.Open()
Dim str As String
str = "update [pctable] set [Person Incharge] = '" & TbPI.Text & "', [DeptSection] = '" & TbDS.Text & "', [Workgroup] = '" & TbWG.Text & "', [Network ID] = '" & TbNI.Text & "', [OS] = '" & TbOS.Text & "', [Processor] = '" & TbProcessor.Text & "', [MOBO] = '" & TbMB.Text & "', [Memory] = '" & TbRAM.Text & "', [HDD] = '" & TbHDD.Text & "', [Product Key] = '" & TbKey.Text & "', [MS Office] = '" & CbMS.SelectedValue & "', [Open Office] = '" & tbOO.Text & "', [Anti Virus] = '" & TbAV.Text & "', [Monitor] = '" & TbMonitor.Text & "', [Email Address] = '" & TbEadd.Text & "', [Date Purchased] = '" & TbDP.Text & "', [Machine Type] = '" & comboMT.SelectedValue & "', [Remarks] = '" & TbRM.Text & "', [Password] = '" & TbPW.Text & "' Where [PCNumber] = '" & TbPCnum.Text & "'"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myConnection.Close()
TbPCnum.Clear()
TbPI.Clear()
TbDS.Clear()
TbWG.Clear()
TbNI.Clear()
TbOS.Clear()
TbProcessor.Clear()
TbMB.Clear()
TbRAM.Clear()
TbHDD.Clear()
TbKey.Clear()
tbOO.Clear()
TbAV.Clear()
TbMonitor.Clear()
TbEadd.Clear()
TbDP.Clear()
TbRM.Clear()
TbPW.Clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub发布于 2015-10-21 08:32:06
我怀疑这可能是您的查询字符串。例如,您发送一个字符串/文本,而不是int/number。
检查它,并确保数据库列类型与您通过查询发送的数据匹配。
如果发送int/数值,则删除单引号。
https://stackoverflow.com/questions/33250114
复制相似问题