Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ms access Stored Procedure - I am getting an empty DataSet when running a stored query

ms access Stored Procedure - I am getting an empty DataSet when running a stored query

Scheduled Pinned Locked Moved C#
databasetoolshelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    astroudjr
    wrote on last edited by
    #1

    I run the query in access and it populates results fine. It is a simple select command. I think I might just have the code wrong somewhere just can't figure it out. Please help. The headers populate in the datagridview but none of the data does.

    private void QueryTest()
    {
    pcDataConn = Utility.DBConnection();
    try
    {
    OleDbCommand cmd = new OleDbCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Connection = pcDataConn;
    cmd.CommandText = "FHD_qry";
    DataSet ds = new DataSet();
    OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
    adapter.Fill(ds);
    DataTable dt = ds.Tables[0];
    pcDataview.DataSource = dt;
    int totalResults = dt.Rows.Count;
    Resultslabel.Text = "Results: " + dt.Rows.Count.ToString();
    if (totalResults > 0)
    {
    Exportbutton.Enabled = true;
    }
    else
    {
    Exportbutton.Enabled = false;
    }

            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
            pcDataConn.Close();
         }
    
    A 1 Reply Last reply
    0
    • A astroudjr

      I run the query in access and it populates results fine. It is a simple select command. I think I might just have the code wrong somewhere just can't figure it out. Please help. The headers populate in the datagridview but none of the data does.

      private void QueryTest()
      {
      pcDataConn = Utility.DBConnection();
      try
      {
      OleDbCommand cmd = new OleDbCommand();
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Connection = pcDataConn;
      cmd.CommandText = "FHD_qry";
      DataSet ds = new DataSet();
      OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
      adapter.Fill(ds);
      DataTable dt = ds.Tables[0];
      pcDataview.DataSource = dt;
      int totalResults = dt.Rows.Count;
      Resultslabel.Text = "Results: " + dt.Rows.Count.ToString();
      if (totalResults > 0)
      {
      Exportbutton.Enabled = true;
      }
      else
      {
      Exportbutton.Enabled = false;
      }

              }
              catch(Exception ex)
              {
                  Console.WriteLine(ex.Message.ToString());
              }
              pcDataConn.Close();
           }
      
      A Offline
      A Offline
      astroudjr
      wrote on last edited by
      #2

      I figured it out. It was the whole wildcard through the OleDb connection. I just changed the ?'s to #'s in the stored procedure and it worked fine.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups