[ad_1]
Sub read() Dim constring As String = "dsn=mysql_tabel;database=db1;server=localhost;iud=root" Dim con As New OdbcConnection(constring) 'Dim con As New OdbcCommand(SQL) 'dataload() con.Open() Dim query As String = "Select *From tbdata_reservasi" Dim cmd As New OdbcCommand(query, con) Dim dr As OdbcDataReader = cmd.ExecuteReader() While dr.Read Dim RoomNum_R As Integer = dr.GetInt32(7) Dim startdate As DateTime = dr.GetDate(9) Dim enddate As DateTime = dr.GetDate(10) Dim startdate_c As Integer = startdate.Day Dim enddate_c As Integer = enddate.Day Dim room1 As Integer = RoomNum_R - 1 Dim totaldays As Integer = enddate_c - startdate_c DG1(startdate_c, room1).Style.BackColor = Color.Red For i = 1 To totaldays DG1(startdate_c + i, room1).Style.BackColor = Color.Red totaldays -= 1 'totaldays = -1 Next End While End Sub What I have tried: i dont know for solution,if the number of RoomNum only 1 digit there is no error,but if mor digit at the RoomNum it will be error "<pre>Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
解決策 1
それはあなたのように見えます DG1
配列(それが何であれ)には十分な部屋がありません…:-)
洞察を得るためにデバッガーを使用することをお勧めします。
[ad_2]
コメント