aminhexa
چهارشنبه 10 آبان 1391, 18:35 عصر
سلام
خطای string or binary data would be truncated . The statement has been terminated. برای چیست؟
programerinfonet
چهارشنبه 10 آبان 1391, 18:59 عصر
دوست عزیز اگر اشتباه نکنم میگه که کدت کوتاه و یا ناقصه
اگه می تونی کدتو بذار تا بیشتر راهنماییت کنیم
aminhexa
چهارشنبه 10 آبان 1391, 19:56 عصر
SqlConnection con = new SqlConnection(constring);
                    con.Open();
                    SqlCommand cmd = new SqlCommand("insert into Customer (ccode,cname,clname,cfname,cshcode,cmcode,ctel,cph one,cco,caddress,cpostal) values('" + Int32.Parse(txtId.Text) + "','" + txtCname.Text + "','" + txtClname.Text + "','" + txtCfname.Text + "','" + txtCshenasname.Text + "','" + txtCmcode.Text + "','" + txtCtel.Text + "','" + txtCphone.Text + "','" + txtCco.Text + "','" + txtCaddress.Text + "','" + txtCpostal.Text + "')", con);
                    cmd.ExecuteNonQuery();
                    con.Close();
r_s1389@yahoo.com
چهارشنبه 10 آبان 1391, 20:16 عصر
سلام 
توصیه میکنم از اون روش برای ذخیره در دیتابیس استفاده نکنید چون امان اشتباه (تایپی) زیاد میشه
SqlConnection con = new SqlConnection("data source=(local);initial catalog=db;integrated security=true;");
            SqlCommand cmd = new SqlCommand("insert into T2 (name,fname) values (@name,@fname)", con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@name", textBox1.Text);
            cmd.Parameters.AddWithValue("@fname", textBox2.Text);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
از این روش که به صورت پارامتری است استفاده کنید
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.