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];
}
}
{
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();
}
{
ordercls oc = new ordercls();
string srch = Convert.ToString(txtsrch.Text).Trim();
DataTable objdt = oc.odrsrch();
gv.DataSource = objdt;
gv.DataBind();
}

Amit GuptaRank #190 · 12.8K reputationPosted Apr 17, 2018, 4:46 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Apr 17, 2018, 7:53 AM EDT