Dim Current As String
Current = Directory.GetCurrentDirectory()
con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data Source = " & Current & "\SchoolMaticsDatabase.mdb"
con.Open()
TabSelect()
con.Close()
Private Sub TabSelect()
Select Case TabControl1.SelectedIndex
Case Is = 0
TabDay = "Monday"
Case Is = 1
TabDay = "Tuesday"
Case Is = 2
TabDay = "Wednesday"
Case Is = 3
TabDay = "Thursday"
Case Is = 4
TabDay = "Friday"
Case Is = 5
TabDay = "Saturday"
Case Is = 6
TabDay = "Sunday"
End Select
ds.Clear()
sql = "SELECT [Forename],[Surname],[Subject Speciality 1],[Subject Speciality 2],[Subject Speciality 3],[Subject Speciality 4],[Subject Speciality 5],[Subject Speciality 6]," & StartTime & "," & EndTime & ",[Spec1],[Spec2],[Spec3],[Spec4],[Spec5],[Spec6] FROM [Staff] WHERE " & TabDay & " LIKE 'T'"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "SchoolMaticsDatabase")
End Sub
da.fill(DS, “SchoolMaticsDatabase”)>>>这行代码出现错误。
如果更改了选项卡索引,则还会调用子TabSelect()。另一件事是程序检查星期几并正确显示与当天相对应的选项卡。星期一这个代码工作正常,只要它在星期二达到这个错误就会出现。
答案 0 :(得分:0)
尝试将conn作为参数传递给TabSelect()函数。 TabSelect(ByRef OleDbConnection conn)
由于你正在玩全局变量