help about dataset

Discussion in 'ASP .Net Datagrid Control' started by indra, May 26, 2005.

  1. indra

    indra Guest

    Hi,

    do you know why i got error on this:



    da = new SqlDataAdapter();

    ds = new DataSet();

    da.SelectCommand.CommandText=" SELECT EmployeeID, LastName, FirstName FROM
    Employees ";

    da.SelectCommand.Connection = cnn;

    da.Fill(ds);



    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set
    to an instance of an object.

    Source Error:

    Line 390: da = new SqlDataAdapter();
    Line 391: ds = new DataSet();
    Line 392: da.SelectCommand.CommandText="SELECT EmployeeID, LastName,
    FirstName FROM Employees";Line 393: da.SelectCommand.Connection = cnn;
     
    indra, May 26, 2005
    #1
    1. Advertising

  2. Have you verified your syntax?

    SqlDataAdapter da = new SqlDataAdapter();

    "indra" <> wrote in message
    news:%...
    > Hi,
    >
    > do you know why i got error on this:
    >
    >
    >
    > da = new SqlDataAdapter();
    >
    > ds = new DataSet();
    >
    > da.SelectCommand.CommandText=" SELECT EmployeeID, LastName, FirstName FROM
    > Employees ";
    >
    > da.SelectCommand.Connection = cnn;
    >
    > da.Fill(ds);
    >
    >
    >
    > Object reference not set to an instance of an object.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.NullReferenceException: Object reference not set
    > to an instance of an object.
    >
    > Source Error:
    >
    > Line 390: da = new SqlDataAdapter();
    > Line 391: ds = new DataSet();
    > Line 392: da.SelectCommand.CommandText="SELECT EmployeeID, LastName,
    > FirstName FROM Employees";Line 393: da.SelectCommand.Connection = cnn;
    >
    >
    >
    >
    >
     
    Ken Cox [Microsoft MVP], May 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,802
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    527
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. Joseph D. DeJohn

    DataSet to DataSet

    Joseph D. DeJohn, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    401
  4. Nedu N
    Replies:
    2
    Views:
    2,161
  5. William Gower
    Replies:
    2
    Views:
    4,146
    Brian Baker [MVP]
    Jul 26, 2004
Loading...

Share This Page