CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2013

    DataAdapter.Fill not returning results

    Due to contract rules I cannot post exact code on my issue. However if I describe the issue, someone may have had the same issue.
    I have a common routine that is passed a given SQL table name. Given this table name, I access and call a stored procedure with two parameters. Then I access the stored procedure via "DataAdapter.fill(ds)" where "ds" is a dataset object.
    This process works for 11 out of 12 of my stored procedures and the fill does fill out the dataset. However, 1 stored proc is not filling the "ds" on the fill command. I can call the stored procedure in MS SQL Manager fine and it works. What is coming back from the "fill" is a bogus return dataset of the literal "1" or sometimes "6".
    I have tried everthing I know and no luck getting this one to work. As a work-around, I embeded the code with the T-SQL script to get the table data and that works too.
    Ideas anyone? Thanks

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: DataAdapter.Fill not returning results

    Might be the name? Provide that, with some hidden fields. googleDB would show as MyDb

    Otherwise, post the LOG files (with same advice)

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2004
    Kashmir, India

    Re: DataAdapter.Fill not returning results

    Does your stored procedure actually return a dataset?

    You can always post a sample code instead of the exact working code that you have in your application.

  4. #4
    Join Date
    Dec 2013

    Re: DataAdapter.Fill not returning results

    DataSet ds = new DataSet();
    SqlConnection con = new SqlConnection(GetConnectionString());
    SqlCommand cmd = new SqlCommand(GetStoredProcedure(tableName), con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da = new SqlDataAdapter(cmd);
    da.SelectCommand.CommandType = CommandType.StoredProcedure;
    da.SelectCommand.Parameters.Add("@Parm1", SqlDbType.VarChar).Value = Parm1;
    da.SelectCommand.Parameters.Add("@Parm2_ID", SqlDbType.VarChar).Value = Parm2;
    if (con.State == ConnectionState.Closed)
    int i = da.Fill(ds);
    if (con.State == ConnectionState.Open)
    GetStoredProcedure is a method that will provide the stored procedure available on the server depending onthe table name being passed.

Tags for this Thread

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)