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

Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Apr 1, 2015, 5:49 PM EDT
you are defined two argument but passing three arguments
in your Sp you do no define @glCode it may be possible that error was occur due to this
@glCode
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Apr 1, 2015, 8:29 AM EDT
So first check your SP in DB and for this you can use this query
EXEC SP_HelpText 'STOREDProcedure Name'
and check that there is no of argument are same as no of parameters which your passing or not.
Peter Dzuya156 reputationPosted Apr 1, 2015, 8:53 AM EDT
Vergel Aranas8 reputationPosted Apr 1, 2015, 10:12 AM EDT
Peter Dzuya156 reputationPosted Apr 1, 2015, 9:43 PM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Apr 2, 2015, 4:53 AM EDT