我的datagridview代码有问题。我需要用它来预定一个问题。我能够添加到数据库但我的问题是从数据库中重新获取数据,而我使用表来安排医生的时间(下面是代码)。现在我需要从包含患者姓名的另一个表中填充数据库中的单元格。我不能这样做。我很多想,但我不能这样做
Private Sub Appointment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AppSlot.RowTemplate.Height = 65
Call AccessConnection()
' below code is to retrive the time of each doctor
SqlQuery = "select * from DTest"
comnd = New OleDbCommand(SqlQuery, Conn)
Dim dr As OleDbDataReader
Dim starttime As New DateTime
Dim endtime As New DateTime
Dim duration As New TimeSpan
Dim SlotDuration As Integer
dr = comnd.ExecuteReader
If dr.HasRows Then
While dr.Read
endtime = dr.Item("ToT")
starttime = dr.Item("FromT")
SlotDuration = dr.Item("Duration")
End While
duration = TimeValue(endtime) - TimeValue(starttime)
Dim Dur As Integer = duration.Hours
Dur = (Dur * 60) / SlotDuration
For i As Integer = 0 To Dur - 1
Me.AppSlot.Rows.Add(starttime.ToString("hh:mm"))
starttime = starttime.AddMinutes(SlotDuration)
Next
' below code is to set the coulmn header which i add it manually
AppSlot.Columns(1).HeaderText = Today.ToString("dddd dd/MM/yyyy")
AppSlot.Columns(2).HeaderText = Today.AddDays(1).ToString("dddd dd/MM/yyyy")
AppSlot.Columns(3).HeaderText = Today.AddDays(2).ToString("dddd dd/MM/yyyy")
AppSlot.Columns(4).HeaderText = Today.AddDays(3).ToString("dddd dd/MM/yyyy")
AppSlot.Columns(5).HeaderText = Today.AddDays(4).ToString("dddd dd/MM/yyyy")
AppSlot.Columns(6).HeaderText = Today.AddDays(5).ToString("dddd dd/MM/yyyy")
AppSlot.Columns(7).HeaderText = Today.AddDays(6).ToString("dddd dd/MM/yyyy")
AppSlot.Columns(0).Width = 40
AppSlot.Columns(0).DefaultCellStyle.BackColor = Drawing.Color.AliceBlue
Dim fon As Font
fon = New Font(AppSlot.Font, FontStyle.Bold)
AppSlot.Columns(0).DefaultCellStyle.Font = fon
End If
End Sub
上述代码中的第一个查询是获取医生的时间表 我不知道如何从患者预约表中进行另一个查询并填写预约的预约单元格,并将空白单元格留空。
例如,下面是包含医生1的时间表的表。
ID FromT ToT Duration Doctor
1 9:00 11:00 20 1
所以,现在第一个查询将根据上表中的时间在datagridview中添加行。
网格视图如下所示。现在我无法填充数据库中的空闲单元格
Time Sat Sun Mon Tue Wed Thu Fri
9:00
9:20
9:40
10:00
10:20
10:40
我希望我能够清楚地了解我需要什么