i have using a SqlDataReader to fill the repeater with this function , it works fine
String SelCmd="Select * from TblFRProduct order by Prod_id";
SqlCommand myCommand=new SqlCommand(SelCmd,myConnection);
myCommand.Connection.Open();
SqlDataReader dr= myCommand.ExecuteReader();
Repeater1.DataSource=dr;
Repeater1.DataBind();
myCommand.Connection.Close();
after that i have decided to use the SqlDataReader which was opened and get another record from database ,so i did so
String SelCmd="Select * from TblFRProduct order by Prod_id";
SqlCommand myCommand=new SqlCommand(SelCmd,myConnection);
myCommand.Connection.Open();
SqlDataReader dr= myCommand.ExecuteReader();
Repeater1.DataSource=dr;
Repeater1.DataBind();
dr.Close();
SelCmd="Select * from TblFRProduct prod_id=@id";
myCommand.CommandText=SelCmd;
myCommand.Parameters.Add(new SqlParameter("@id",SqlDbType.Int));
myCommand.Parameters["@id"].Value=System.Convert.ToInt32(MinProd_Id,10);
dr= myCommand.ExecuteReader();
LblProduct.Text=dr["description"].ToString();
myCommand.Connection.Close();
but i get this error
Incorrect syntax near '='.
the red line is that on dr= myCommand.ExecuteReader();
i am sure that parameters["@id"] is filled correctly. but it seems i can not use the SqlDataReader that i have used before. how can i do that?
String SelCmd="Select * from TblFRProduct order by Prod_id";
SqlCommand myCommand=new SqlCommand(SelCmd,myConnection);
myCommand.Connection.Open();
SqlDataReader dr= myCommand.ExecuteReader();
Repeater1.DataSource=dr;
Repeater1.DataBind();
myCommand.Connection.Close();
after that i have decided to use the SqlDataReader which was opened and get another record from database ,so i did so
String SelCmd="Select * from TblFRProduct order by Prod_id";
SqlCommand myCommand=new SqlCommand(SelCmd,myConnection);
myCommand.Connection.Open();
SqlDataReader dr= myCommand.ExecuteReader();
Repeater1.DataSource=dr;
Repeater1.DataBind();
dr.Close();
SelCmd="Select * from TblFRProduct prod_id=@id";
myCommand.CommandText=SelCmd;
myCommand.Parameters.Add(new SqlParameter("@id",SqlDbType.Int));
myCommand.Parameters["@id"].Value=System.Convert.ToInt32(MinProd_Id,10);
dr= myCommand.ExecuteReader();
LblProduct.Text=dr["description"].ToString();
myCommand.Connection.Close();
but i get this error
Incorrect syntax near '='.
the red line is that on dr= myCommand.ExecuteReader();
i am sure that parameters["@id"] is filled correctly. but it seems i can not use the SqlDataReader that i have used before. how can i do that?