[SqlException (0x80131904): 将截断字符串或二进制数据。 语句已终止。] 神马问题啊,求解决。 5
行80:SqlCommandcmd=newSqlCommand("insertintoUsers(UserName,Password,EmailAdress)values...
行 80: SqlCommand cmd = new SqlCommand("insert into Users(UserName,Password,EmailAdress) values('"+usrName+ "','"+psw +emd+"','"+"')", conn);
行 81: conn.Open();
行 82: cmd.ExecuteNonQuery();
行 83: conn.Close();
行 84:
源文件: C:\Users\***\documents\visual studio 2010\Projects\WebApplication1\WebApplication1\Account\Register.aspx.cs 行: 82
堆栈跟踪:
[SqlException (0x80131904): 将截断字符串或二进制数据。
语句已终止。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2062078
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5050204
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +228
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +326
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
WebApplication1.Account.Register.Button1_Click(Object sender, EventArgs e) in C:\Users\屈小中\documents\visual studio 2010\Projects\WebApplication1\WebApplication1\Account\Register.aspx.cs:82
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 展开
行 81: conn.Open();
行 82: cmd.ExecuteNonQuery();
行 83: conn.Close();
行 84:
源文件: C:\Users\***\documents\visual studio 2010\Projects\WebApplication1\WebApplication1\Account\Register.aspx.cs 行: 82
堆栈跟踪:
[SqlException (0x80131904): 将截断字符串或二进制数据。
语句已终止。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2062078
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5050204
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +228
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +326
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
WebApplication1.Account.Register.Button1_Click(Object sender, EventArgs e) in C:\Users\屈小中\documents\visual studio 2010\Projects\WebApplication1\WebApplication1\Account\Register.aspx.cs:82
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 展开
展开全部
一般情况是你插入的数据长度超过了这个字段在数据库中定义的长度,
楼主你可以把数据库中的字段的大小设大一点试试,
比如”usrName“的数据类型由原来的varchar(8)改为varchar(32)之类的。。。
楼主你可以把数据库中的字段的大小设大一点试试,
比如”usrName“的数据类型由原来的varchar(8)改为varchar(32)之类的。。。
追问
没有啊,我定义的是16位的,插入的才七位啊,秋高指教啊。
追答
注意看看生成的字符串是否正确:
试试该成这样吧,
SqlCommand cmd = new SqlCommand("insert into Users(UserName,Password,EmailAdress) values('" + usrName + "','" + psw +"','"+ emd + "')", conn);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询