在SQL中插入asp.net问题 [英] asp.net question for inserting in sql

查看:75
本文介绍了在SQL中插入asp.net问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

字符串或二进制数据将被截断.
该声明已终止.

String or binary data would be truncated.
The statement has been terminated.

string insert = "Insert into RentInformation (UserName,EmailId,Password,ConfirmPassword,Purpose,AdTitle,ADType,DescriptionofAd,RoomType,PropertyType,Mobileno,Address,Image) values ('"+TextBox12.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox4.Text+"','"+DropDownList1.SelectedItem+"','"+TextBox18.Text+"','"+DropDownList4.SelectedItem+"','"+TextBox23.Text+"','"+DropDownList5.SelectedItem+"','"+DropDownList6.SelectedItem+"','"+TextBox19.Text+"','"+TextBox20.Text+"','"+Image1.ImageUrl+"') select Purpose from Base where Purpose ='"+DropDownList1.SelectedItem+"' ";


Line 118:            cmd = new SqlCommand(insert,con);
Line 119:            cmd.ExecuteNonQuery();<big> this line generate Exception</big>
Line 120:            con.Close();
Line 121:            Response.Write("<script>alert('insert in RentInformation')</script>");

推荐答案



当您尝试向表中插入的数据多于指定列的大小时,会发生此错误.
检查要在哪个字段中插入其大小大于databsae中定义的大小的值.

像列"的目的是具有大小Varchar(10),并且您尝试插入的值大于10,然后出现此错误,因为它超出了定义的大小.
Hi,

This error occurs when you try insert data into the table more then the specified size of the column.
Check in which field you are trying to insert value whose size is more then the desfined size in databsae.

Like column Purpose is having size Varchar(10) and you are trying to insert value more then 10 then this error because it exceeds the defined size.


这篇关于在SQL中插入asp.net问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆