我正在尝试在VB中连接两个数据表,它们包含在同一个MS访问数据库文件中,并使用新的合并表处理一系列数据绑定过程,但系统会返回一条错误消息,说明如下: / p>
System.Data.dll中出现未处理的“System.Data.OleDb.OleDbException”类型异常
其他信息:无法加入备忘录,OLE或超链接对象(Students.StID = Grades.StID)。
以下是我的代码:
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim constr As String = "Provider = Microsoft.ACE.OLEDB.12.0;" & "Data Source = C:\Users\JohnnyCheng\Documents\GradeBook.accdb"
Dim sqlstr1 As String = "SELECT FirstName, LastName FROM Students INNER JOIN Grades ON Students.StID = Grades.StID"
Dim da = New OleDb.OleDbDataAdapter(sqlstr1, constr)
Dim dset As New DataSet()
Dim source As New BindingSource()
da.Fill(dset)
da.Dispose()
source.DataSource = dset.Tables(0)
BindingNavigator1.BindingSource = source
StIDBox.DataBindings.Add(New Binding("Text", source, "StID", True))
FirstNameBox.DataBindings.Add(New Binding("Text", source, "FirstName", True))
LastNameBox.DataBindings.Add(New Binding("Text", source, "LastNmae", True))
FirstExamBox.DataBindings.Add(New Binding("Text", source, "FirstExam", True))
SecondExamBox.DataBindings.Add(New Binding("Text", source, "SecondExam", True))
FinalExamBox.DataBindings.Add(New Binding("Text", source, "FinalExam", True))
AverageBox.Text = (CDbl(FirstExamBox.Text) + CDbl(SecondExamBox.Text) + CDbl(FinalExamBox.Text) * 2) / 4
End Sub
有人可以帮我解决这个问题吗? 谢谢。