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();
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit GuptaPosted Apr 17, 2018, 8:46 AM
Nitin SontakkePosted Apr 17, 2018, 11:53 AM