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 ChoudharyPosted Apr 1, 2015, 9:49 PM
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 ChoudharyPosted Apr 2, 2015, 8:53 AM
Peter DzuyaPosted Apr 2, 2015, 1:43 AM
Vergel AranasPosted Apr 1, 2015, 2:12 PM
Peter DzuyaPosted Apr 1, 2015, 12:53 PM
Pankaj Kumar ChoudharyPosted Apr 1, 2015, 12:29 PM
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.