6
Answers

display data to reports via a stored proceedure

Peter Dzuya

Peter Dzuya

9y
598
1
Hi All. Still new to C#.
 
I have a code as shown below that I used to obtain data from a stored procedure query that throws an error "Procedure or function 'RptLedgerByDate' has too may arguments specified".
 
 
public bool LoadReport()
{
SqlConnection conReport = new SqlConnection(ConfigurationManager.ConnectionStrings["makConnection"].ToString());
SqlCommand cmdReport = new SqlCommand();
cmdReport.Connection = conReport;
cmdReport.CommandType = CommandType.StoredProcedure;
cmdReport.CommandText = "RPTLedgerByDate";
cmdReport.Parameters.AddWithValue("@glCode", GlCode);
cmdReport.Parameters.AddWithValue ( "@fromDate", FromDate );  
cmdReport.Parameters.AddWithValue ( "@toDate", ToDate );  
SqlDataReader drReport;
DataSet dsReport = new dsReports();
conReport.Open();
drReport = cmdReport.ExecuteReader();
dsReport.Tables[0].Load(drReport);
drReport.Close();
conReport.Close();
if (!(dsReport.Tables[0].Rows.Count > 0))
{
MessageBox.Show("No Available Report Data to Display.",
"SMIS 2015", MessageBoxButtons.OK, MessageBoxIcon.Information);
isReady = false;
this.Close();
}
 
I shall be glad if I get assisted. Thanks 
 
 
Answers (6)