ms access Stored Procedure - I am getting an empty DataSet when running a stored query
-
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(); }
-
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(); }