asdمتغير جاى من صفحة تانية
string asd; asd = Convert.ToString(Request.QueryString["pcode"]); SqlConnection con = new SqlConnection("Password=asd;Persist Security Info=True;User ID=sa;Initial Catalog=hady_workshop;Data Source=NEWLOOK"); con.Open(); SqlCommand cmd = new SqlCommand("Select * From products Where pcode=@pcode", con); cmd.Parameters.Add ("@pcode", asd ); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { TextBox1.Text += dr["pcode"]; } dr.Close(); con.Close();لحد هنا مفيش مشاكلولكن عند عملinsert
string x = Convert.ToString(TextBox1.Text); SqlConnection con = new SqlConnection("Password=asd;Persist Security Info=True;User ID=sa;Initial Catalog=hady_workshop;Data Source=NEWLOOK"); con.Open(); //SqlCommand cmd = new SqlCommand("insert into rate(pcode,comment)values('" + TextBox1.Text + "','" + TextBox2.Text + "')", con); SqlCommand cmd = new SqlCommand("insert into rate(pcode)values('"+x+"')",con); cmd.ExecuteNonQuery(); con.Close();ظهر رسالة خطاString or binary data would be truncated.The statement has been terminated. الفكرة ان القيمة اللى جاية من الصفحة السابقة توضع فى التكست بوكس وهى نفس القيمة التى سوف تخزن فى الداتا بيسالمشكلةفىtextbox1.textاسف جدا والله مااقصد