嗨我一直收到此错误无法找到表映射[表]或数据表。我使用Visual Basic 2013作为桌面,我有一个叫做垃圾的Microsoft Access Table表,我的访问文件的名称是Student.accdb。我的数据集称为StudentDataSet1。我通过Database Explorer添加了数据库,状态为Open。我不是一个程序员,我只是在玩微软Access和VB。此外,我输入连接字符串,它仍然无法正常工作。有人可以帮忙吗?无法映射表
公共类Form1中
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Fill retrieves rows from the data source by using the SELECT statement
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Student.accdb")
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim ds As New DataSet
sql = "Select * from crap "
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim da As OleDb.OleDbDataAdapter
da = New OleDb.OleDbDataAdapter
Dim Department As String
Dim i, ID As Integer
Dim rw As DataRow
'Add a new row to the Student table.
rw = StudentDataSet1.Tables(0).NewRow
ID = InputBox("Enter your ID")
Department = InputBox("Enter your Department")
rw.Item("ID") = ID
rw.Item("Department") = Department
Try
StudentDataSet1.Tables(0).Rows.Add(rw)
'Update the Student table in the testdb database.
i = da.Update(StudentDataSet1)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'Displays number of rows updated.
MessageBox.Show("no of rows updated=" & i)
End Sub
史蒂夫,我把它称为学生,而不是与地址簿和我的点心DS作为StudentDataSet但我不断收到更新需要有效的InsertCommand当新行传递的DataRow集合。 – user3333523
这是另一个问题,我会尝试更新答案。 – Steve
史蒂夫我刚刚尝试了这一点,我不能建立我的解决方案,因为OleDbCommandbuilder没有定义。我有用于桌面的Visual Studio 2013。我可以告诉你我现在拥有什么。 – user3333523