Results 1 to 3 of 3

Thread: error filling dataset during load event

  1. #1
    Addicted Member
    Join Date
    Nov 03
    Location
    Connecticut
    Posts
    250

    error filling dataset during load event

    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

  2. #2
    King of sapila
    Join Date
    Oct 06
    Location
    Greece
    Posts
    3,519

    Re: error filling dataset during load event

    First of all put your code inside "If Not Page.IsPostBack Then". You must also know that your dataset will regenerate after every postback thus you will loose all your data(and must store it if you want to keep it). This is a big difference when programming in asp.net because the web is stateless.
    Slow as hell.

  3. #3
    Addicted Member
    Join Date
    Nov 03
    Location
    Connecticut
    Posts
    250

    Re: error filling dataset during load event

    Ok. I finally got the correct error and it says:

    ex = {"The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine."}

    I have microsoft access loaded and activated on this machine, so I don't understand the error message.

    Any clues? Also, I've used this code many times before on this machine and only now has it given me this error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •