System.Data.SqlClient.SqlException: String or binary data would be truncated. The sta

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harshasri
    New Member
    • May 2014
    • 1

    System.Data.SqlClient.SqlException: String or binary data would be truncated. The sta

    Server Error in '/marksform' Application.

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.Sql Client.SqlExcep tion: String or binary data would be truncated.
    The statement has been terminated.

    Source Error:


    Code:
    Line 61:         SqlCommand cmd = new SqlCommand("insert into resultspage2 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + RadioButtonList1.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "')", con);
    Line 62:         con.Open();
    Line 63:         cmd.ExecuteNonQuery();
    Line 64:         Label1.Text="data inserted successfully";
    Line 65:         con.Close();
    Source File: c:\Users\kclink \Desktop\marksf orm\maksf.aspx. cs Line: 63

    Stack Trace:


    [SqlException (0x80131904): String or binary data would be truncated.
    The statement has been terminated.]
    System.Data.Sql Client.SqlConne ction.OnError(S qlException exception, Boolean breakConnection ) +2030802
    System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion exception, Boolean breakConnection ) +5009584
    System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning() +234
    System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleR esultSet bulkCopyHandler , TdsParserStateO bject stateObj) +2275
    System.Data.Sql Client.SqlComma nd.RunExecuteNo nQueryTds(Strin g methodName, Boolean async) +228
    System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult result, String methodName, Boolean sendToPipe) +326
    System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +137
    maksf.Button1_C lick(Object sender, EventArgs e) in c:\Users\kclink \Desktop\marksf orm\maksf.aspx. cs:63
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +118
    System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument) +112
    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +10
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +36
    System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +5563
    Last edited by Rabbit; May 23 '14, 12:03 AM. Reason: Please use [code] and [/cod]e tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    That error means you're trying to insert data that is too big for the column you're trying to insert it into.

    Comment

    Working...