Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Intialy i extracting data from Sql server database and displaying in gridview of a webform`s page load event, that fucnttion is as follows:

C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetData(); 
            }
        }
private void GetData()
     {
      GViewIncidentDetails .DataSource = dbpinsidentdetails.RunSPReturnDataSet     ("GET_INCIDENTDETAILS");
          GViewIncidentDetails.DataBind();
}

following is the code for function RunSPReturnDataSet():
C#
public DataSet RunSPReturnDataSet(string spname)
		{
			SqlDataAdapter dataAdapter=new SqlDataAdapter();
			DataSet dataSet=new DataSet();

			Com.CommandText=spname;
			Com.CommandType =CommandType.StoredProcedure;
  
			dataAdapter.SelectCommand =Com;
			dataAdapter.Fill(dataSet);
 
			return dataSet; 
	
		}
}


after displaying data in gridview i am editing one record by calling "RowUpdating" event of gridview by folling code:
C#
 protected void GViewIncidentDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow r = GViewIncidentDetails.Rows[e.RowIndex];
                dbpinsidentdetails.InputParam("@iIDID", Convert.ToInt32(r.Cells[1].Text));
                DropDownList ddl1 = (DropDownList)r.Cells[8].Controls[0];
                string ddlstring = ddl1.SelectedValue.ToString();
                dbpinsidentdetails.InputParam("@iStatus", ddlstring);
                dbpinsidentdetails.RunSPReturnVoid("UPDATE_INCIDENTDETAILS");
               GViewIncidentDetails.EditIndex = -1;
                GetData();            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
}
following is the code for function RunSPReturnVoid():
 public void RunSPReturnVoid(string spname)
		{
			Com.CommandText =spname;
			Com.CommandType =CommandType.StoredProcedure; 
			Com.ExecuteNonQuery(); 			
		}


In this function after calling a SP for updation, i called the GetData() function to display the data after changes which are made now to gridview.

I am getting an error here that is "
Procedure GET_INCIDENTDETAILS has no parameters and arguments were supplied. 
"

any way record is updateing correctly.

Actualy GET_INCIDENTDETAILS stored procedure does`t have any arguments, here problem is arguments of UPDATE_INCIDENTDETAILS are passing to GET_INCIDENTDETAILS stored procedure.

Please any body explain me what is the reason for this error, what i need to do avoid this error.

Please help me.

Thanks in addvance

K Uday
Posted
Updated 25-Aug-11 20:44pm
v2

Difficult to follow your code and explanation, but you seem to have at least one object (com) that you are using in dbpinsidentdetails.

Once you have added paramters to an object, if ou don't recreate that object then the paramter(s) will still be there - so when you reuse the object for your Select, it will pass the parameter(s) it already has.

You don't show the code for dbpinsidentdetails.InputParam(...) - I would guess that it is in there that you add your parameter to some object - and the object is retained between uses and so, then , are the parameters.
 
Share this answer
 
Comments
udaysimha 26-Aug-11 4:40am    
Thaks for your reply, i understanded what your sad, here i am show the code for

dbpinsidentdetails.InputParam(...), please gothrough the code and advise me.

public void InputParam(string paramName,int paramValue)

{ Param= Com.Parameters.Add(paramName,SqlDbType.Int);

Param.Direction=ParameterDirection.Input;

Param.Value = paramValue; }

Note: second argument 'paramValue' will change based on input data type.Thanks

K Uday
XML
Yep - so your Com object has the parameter added to its collection of parameters

com.parameters.add(...)

and you never remove them, and I guess never re-create your Com object.

Easiest way to go about this is to change the place you instantiate your Com objeect - instead of doing so once, then reusing it, instantiate a new copy for each call to an SP

Hope that makes sense

<b></b>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900