Richa Chunekar

Richa Chunekar

  • NA
  • 6
  • 459

Store procedure

Apr 17 2018 7:36 AM
i have made a function in class file to call store procedure to fatch data from data base, the function is written below.
public DataTable odrsrch()
{
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
connection.Open();
SqlCommand com = new SqlCommand("ordersp", connection);
com.CommandType = CommandType.StoredProcedure;

SqlDataAdapter adp = new SqlDataAdapter(com);
DataSet ds = new DataSet();
adp.Fill(ds, "ordersp");
connection.Close();
return ds.Tables[0];
}
} 
and at button i have called the mathed using class object, but i am not getting result.
protected void btnsrch_Click(object sender, EventArgs e)
{
ordercls oc = new ordercls();
string srch = Convert.ToString(txtsrch.Text).Trim();
DataTable objdt = oc.odrsrch();
gv.DataSource = objdt;
gv.DataBind();

}
 

Answers (2)