B
bazzer
im filling a datset with names of films and need to get the number of
films in the dataset. basically i want to know if its empty. but when
i try and get the number of rows it gives me the error: "Object
reference not set to an instance of an object" . I get this error from
the line:"Label3.Text =
CalendarFilmsDataSet11.Tables("Customers").Rows.Count". and i get the
error whether the dataset has items in it or not. can anyone tell me
why this is happening.
this is my code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Label2.Text = "Films Showing on " + Session("theShowDate")
CalendarFilmsDataSet11.Clear()
OdbcDataAdapter1.SelectCommand.Parameters("cinemaID").Value
= Session("theCinemaID")
OdbcDataAdapter1.SelectCommand.Parameters("showDate").Value
= Session("theShowDate")
OdbcDataAdapter1.Fill(CalendarFilmsDataSet11)
Label3.Text =
CalendarFilmsDataSet11.Tables("Customers").Rows.Count
ListBox1.DataBind()
End If
End Sub
films in the dataset. basically i want to know if its empty. but when
i try and get the number of rows it gives me the error: "Object
reference not set to an instance of an object" . I get this error from
the line:"Label3.Text =
CalendarFilmsDataSet11.Tables("Customers").Rows.Count". and i get the
error whether the dataset has items in it or not. can anyone tell me
why this is happening.
this is my code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Label2.Text = "Films Showing on " + Session("theShowDate")
CalendarFilmsDataSet11.Clear()
OdbcDataAdapter1.SelectCommand.Parameters("cinemaID").Value
= Session("theCinemaID")
OdbcDataAdapter1.SelectCommand.Parameters("showDate").Value
= Session("theShowDate")
OdbcDataAdapter1.Fill(CalendarFilmsDataSet11)
Label3.Text =
CalendarFilmsDataSet11.Tables("Customers").Rows.Count
ListBox1.DataBind()
End If
End Sub