User651828378 posted
Hi i have this code, where i get some dates from a db into a dayrender and then showing a calendar.
But in getting an error about, where it cant find the tables !?
Im new to this so i dont know what to look after.
For Each dr In ds.Tables(0).Rows
My code is
Dim ds As New DataSet
Dim dsSelDate As DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnStr").ConnectionString)
Using cmd As OleDbCommand = New OleDbCommand()
cmd.Connection = connection
cmd.CommandText = String.Format("SELECT * FROM event_cal")
Using adapter As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim ds As New DataSet()
adapter.Fill(ds, "AllTables")
connection.Close()
End Using
End Using
End Using
If Not IsPostBack Then
End If
End Sub
'Day Render
Protected Sub DayRender(sender As Object, e As DayRenderEventArgs)
If Not e.Day.IsOtherMonth Then
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
'If EventDate is not Null
If Not dr("event_date") Is DBNull.Value Then
Dim dtEvent As DateTime = dr("event_date").ToString
'If EventDate =CalendarDate
If dtEvent.Equals(e.Day.Date) Then
e.Cell.BackColor = Color.PaleVioletRed
e.Cell.BorderColor = System.Drawing.Color.Pink
e.Cell.Font.Italic = True
e.Cell.Font.Size = FontUnit.Large
End If
End If
Next
'If the month is not CurrentMonth then hide the Dates
Else
e.Cell.Text = ""
End If
End Sub