hi, I am trying to populate datalist with a dataset using parameterised procedure, here is my code
string str=Request.Params["producttype"];
SqlDataAdapter da=new SqlDataAdapter( "pt3",this.sqlConnection1);
da.SelectCommand.CommandType=CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add(new SqlParameter("@ptype", SqlDbType.NVarChar,20));
da.SelectCommand.Parameters["@ptype"].Value=str;
DataSet ds= new DataSet();
this.sqlConnection1.Open();
da.Fill(ds,"product");
this.DataList1.DataSource=ds;
this.DataList1.DataBind();
and my procedure is
create procedure pt3
@ptype nvarchar(20)
as
select productcode, productname,productdescription,unitprice from product where producttype=@ptype
go
I don't know why is it giving me that exception. Please help me out with an answer.
string str=Request.Params["producttype"];
SqlDataAdapter da=new SqlDataAdapter( "pt3",this.sqlConnection1);
da.SelectCommand.CommandType=CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add(new SqlParameter("@ptype", SqlDbType.NVarChar,20));
da.SelectCommand.Parameters["@ptype"].Value=str;
DataSet ds= new DataSet();
this.sqlConnection1.Open();
da.Fill(ds,"product");
this.DataList1.DataSource=ds;
this.DataList1.DataBind();
and my procedure is
create procedure pt3
@ptype nvarchar(20)
as
select productcode, productname,productdescription,unitprice from product where producttype=@ptype
go
I don't know why is it giving me that exception. Please help me out with an answer.