Results 1 to 3 of 3

Thread: Newbie -> System.NullReferenceException

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    Newbie -> System.NullReferenceException

    When running below codes, I met the following error message

    An unhandled exception of type 'System.NullReferenceException' occurred in NetAdmin.exe

    Additional information: Object reference not set to an instance of an object.


    Private Sub LoadRemoteHost()
    Dim SQLDA1 As New SqlClient.SqlDataAdapter
    Dim dataset As New DataSet

    '
    SQLDA1.SelectCommand.Connection = SQLConn0
    SQLDA1.SelectCommand.CommandType = CommandType.StoredProcedure
    SQLDA1.SelectCommand.CommandText = "usp_showremotehost"

    dataset.Clear()
    SQLDA1.Fill(dataset)

    Me.C1TrueDBGrid1.DataSource = dataset.Tables("RemoteHost")
    End Sub


    Am I missing something? .. please advise ..many thanks in advance

    Regards
    Winan

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    it means an object you are using has been declared, but hasn't been set to anything yet...

    where does the var SQLConn0 come from?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    RESOLVED

    Thanks the problem has been resolved .. by running below codes:

    Dim SQLDataAdapter As New SqlClient.SqlDataAdapter("usp_showremotehost", SQLConn0)
    Dim DSRemoteHost As New DataSet("RemoteHost")
    SQLDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
    DSRemoteHost.Clear()
    SQLDataAdapter.Fill(DSRemoteHost, "RemoteHost")

    ..
    ..
    ..

    SQLConn0 declared as public variable in a module

    Regards
    Winan

Posting Permissions

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



Click Here to Expand Forum to Full Width