locked
oledbadapter fill method RRS feed

  • Question

  • Hi

     I am filling datatable using oledbadapter method, so if fetched data is empty fill method throws exception:

    "Value cannot be null.Parameter name: dataTable"

    below is snippet code:

      

     	string Query;
    
                //Query to select the user from the database
                Query = "select IRNO from shipdetails where IRNO='"+IRnum +"'";
    
                //Assign query to oledb command
                command.CommandText = Query;
    
                //open the connection to the DB
                connection.Open();
    
                //Adapter initialization
                Adapter.SelectCommand = command;
    
                //Fill the datatable 
                Adapter.Fill(ShipDetail);
    • Moved by Mike Dos Zhang Monday, September 24, 2012 4:53 AM DataAdapter (From:General Windows Desktop Development Issues)
    Friday, September 21, 2012 9:51 AM

Answers

  • Can you share your code related ShipDetail.

    Seems ShipDetail which is a Datatable and this instance is not initilized.


    Lingaraj Mishra


    • Edited by Lingaraj Mishra Monday, September 24, 2012 8:58 AM
    • Proposed as answer by Bob Wu-MT Tuesday, September 25, 2012 7:56 AM
    • Marked as answer by Min Zhu Tuesday, October 9, 2012 9:38 AM
    Monday, September 24, 2012 8:58 AM

All replies

  • This is a Data aspect question, please us this Data forum.

    Best wishes,


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 24, 2012 4:53 AM
  • Can you share your code related ShipDetail.

    Seems ShipDetail which is a Datatable and this instance is not initilized.


    Lingaraj Mishra


    • Edited by Lingaraj Mishra Monday, September 24, 2012 8:58 AM
    • Proposed as answer by Bob Wu-MT Tuesday, September 25, 2012 7:56 AM
    • Marked as answer by Min Zhu Tuesday, October 9, 2012 9:38 AM
    Monday, September 24, 2012 8:58 AM
  • I'm agree with Lingaraj, try initialize the ShipDetail table.

    ShipDetail = new DataTable();

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Bob Wu-MT Tuesday, September 25, 2012 7:58 AM
    Tuesday, September 25, 2012 7:58 AM