I am new to asp.net and I'm trying to build my first web page, but when I try to fill a dataset at the page load event I get an error:
object reference not set to instance of object.
Am I missing something? I've done this many times in vb.net. I can't figure out how to step through my code like I do when I'm creating a desktop app, so I don't know exactly where it's failing. I like to be able to see the values of things as it goes through the code.
Code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label2.Visible = False Dim dsCheckExisting As New System.Data.DataSet() dsCheckExisting.Clear() Dim adLookup As New OleDb.OleDbDataAdapter adLookup.SelectCommand = New OleDb.OleDbCommand Dim cnxAd As New OleDb.OleDbConnection cnxAd.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Chr(34) & "C:\xxx\db1.mdb" & Chr(34) & "" Dim joe As String = "OCYNFC005679699.994/21/20125/5/2012" With adLookup.SelectCommand .Connection = cnxAd .CommandText = "select * from sheet1 where [unique]=" & joe & "" .CommandType = CommandType.Text End With Try cnxAd.Open() adLookup.Fill(dsCheckExisting, "sheet1") cnxAd.Close() Catch ex As Exception cnxAd.Close() End Try Dim dr As DataRow If dsCheckExisting.Tables("sheet1").Rows.Count > 0 Then For Each dr In dsCheckExisting.Tables("sheet1").Rows Label1.Text = dr("booked") Next End If End Sub


Reply With Quote