vendredi 7 mars 2014

Want to create dynamic method for calling procedure


Vote count:

0




My aspx.cs calling



protected void btnState_Click(object sender, EventArgs e)
{
SqlParameter param = new SqlParameter();
param.Direction
param[0].ParameterName = "@state";
param[0].Value = txtState.Text;
obj.insrtsp("SpInsertState", param);
}


Method in Class file as my input



public void insrtsp(string str, SqlParameter[] param )
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = str;
cmd.ExecuteNonQuery();

}


right now i am using stored procedure in a way that everytime i have to type whole things while executing it but i want to create a dynamic method for stored procedure by which i can just create object of that method and call procedure by passing arguments.


is there any suggestions.?



asked 43 secs ago






Aucun commentaire:

Enregistrer un commentaire