use sql in query in store procedure and fill datatable by fetching records
store procedure it not wok
alter procedure getproductbycategory
@categoryid varchar
as
select
pe.pid,
pe.procode,
pe.img1,
pe.proname,
rm.salerate,
rm.disrate,
rm.qty,
rm.unitname,
rm.unit,
rm.realqty,
rm.realqtyunitname,
rm.realqtyunit
from tbl_productentry as pe
left join tbl_ratemaster as rm on pe.pid =rm.pid
left join tbl_productcategory as pc on (pe.pid=pc.pid)
where pc.categoryid in(@categoryid)
go
my code is
public static string GetProductlist(string groupid, string subgroupid, string itemetypeid, string categoryid, string sid, string sid3,string s4id)
{
DataTable dt = new DataTable();
if (categoryid != "0")
{
string query = "getproductbycategory";
using (SqlConnection con = Connection.getConnection())
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.Parameters.Clear();
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@categoryid", SqlDbType.VarChar).Value = categoryid;
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
sdr.Fill(dt);
cmd.Connection = con;
con.Close();
}
}
}