السلام عليكم
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