无法在Microsoft Access中更新值

时间:2017-06-07 10:08:23

标签: vb.net ms-access

我遇到一个问题,当我尝试更新数据时,程序不会将其保存在数据库中。

这是当前的代码:

Dim y As Byte = Convert.ToByte(lblID.Text) - 1
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("dset").Rows(y).Item(1) = txtname.Text
ds.Tables("dset").Rows(y).Item(2) = txtsubm.Text & "/" & txtsubd.Text & "/" & txtsuby.Text
ds.Tables("dset").Rows(y).Item(3) = txtexpm.Text & "/" & txtexpd.Text & "/" & txtexpy.Text
ds.Tables("dset").Rows(y).Item(5) = txtnotes.Text
If MdComboBox1.SelectedItem = "A" Then
    ds.Tables("dset").Rows(y).Item(4) = "A"
ElseIf MdComboBox1.SelectedItem = "B" Then
Else
    MdAlertBox1.Text = "Please Select A Class The Class Box"
    MdAlertBox1.Visible = True
End If
MdAlertBox1.Text = "Data Sucessfully Updated !"
MdAlertBox1.kind = MDAlertBox._Kind.Success
MdAlertBox1.Visible = True
getinfo.Start()
updatedata.Stop()

声明的变量:

Dim conn As New OleDb.OleDbConnection
Dim DbProv As String = "PROVIDER=microsoft.ACE.OLEDB.12.0;"
Dim Src As String = " data source = c:\users\kingo\documents\visual studio 2013\Projects\WindowsApplication2\WindowsApplication2\BigGymDB.accdb"
Dim da As OleDb.OleDbDataAdapter
Dim ds As New DataSet

1 个答案:

答案 0 :(得分:0)

放置(byte)以查看要传递给数据库的值。像这样:

debug.print

然后在Immdiate Window中的两行中,您应该看到这些 ds.Tables("dset").Rows(y).Item(2) = txtsubm.Text & "/" & txtsubd.Text & "/" & txtsuby.Text ds.Tables("dset").Rows(y).Item(3) = txtexpm.Text & "/" & txtexpd.Text & "/" & txtexpy.Text ds.Tables("dset").Rows(y).Item(5) = txtnotes.Text 'your code ---^ debug.print txtname.Text; txtsubm.Text & "/" & txtsubd.Text & "/" & txtsuby.Text; debug.print txtnotes.Text; txtexpm.Text & "/" & txtexpd.Text & "/" & txtexpy.Text 'your code ---v If MdComboBox1.SelectedItem = "A" Then ds.Tables("dset").Rows(y).Item(4) = "A" ElseIf MdComboBox1.SelectedItem = "B" Then 和其他3个输入是否实际上有什么。