PDA

View Full Version : معرفی پارامتر



myysl97
پنج شنبه 14 فروردین 1393, 09:24 صبح
سلام دوستان به این تکه کد چطوری من پارامتر textbox رو معرفی کنم؟!




string cnf = System.Configuration.ConfigurationManager.Connecti onStrings["god"].ToString();
SqlConnection con = new SqlConnection(cnf);
con.Open();
string str = "select * from tblqustion where qustionname like N'%'+@textbox+'%'";
SqlDataAdapter sdr = new SqlDataAdapter(str, con);
System.Data.DataSet ds = new System.Data.DataSet();
sdr.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();

ali.n93
پنج شنبه 14 فروردین 1393, 10:41 صبح
sdr.SelectCommand.Parameters.AddWithValue("@textbox", TextBox1.Text);