Dear Sir, Thanks to help,
I unable to make update function . while i have update single value in table i have getting mention error.
But while update all value then value updated.
kindly check and help me to remove this.
Server Error in '/' 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.SqlClient.SqlException: String or binary data would be truncated. The statement has been terminated. Source Error:
Line 106:
Line 107: SqlCommand cmd = new SqlCommand("Update cntrct_clsr set tm_ext_upto_dt='" + tm_ext_upto_dt.Text + "',cntrt_cls_trgt_dt='" + cntrt_cls_trgt_dt.Text + "',cntrt_cls_dt='" + cntrt_cls_dt.Text + "',ccp_one='" + DropDownList1 + "',ccp_two='" + DropDownList2 + "',ccp_three='" + DropDownList3 + "' ,ccp_four='" + DropDownList4 + "',ccp_five='" + DropDownList5 + "',ccp_six='" + DropDownList6 + "',ccp_seve='" + DropDownList7 + "',ccp_eight='" + DropDownList8 + "',ccp_nine='" + DropDownList9 + "',ccp_ten='" + DropDownList10 + "',ccp_ele='" + DropDownList11 + "',ccp_tw='" + DropDownList12 + "',ccp_thre='" + DropDownList13 + "',rmrk='" + rmrk.Text + "' where Sr_no=" + Convert.ToInt32(Sr_no.Text), con);
Line 108: cmd.ExecuteNonQuery();
Line 109: con.Close();
Line 110:
|
Source File: c:\Users\Administrator\Documents\Visual Studio 2012\Projects\Cntrct_clsr\Cntrct_clsr\WebForm1.aspx.cs Line: 108 Stack Trace:
[SqlException (0x80131904): String or binary data would be truncated.
The statement has been terminated.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2582782
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6033430
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +297
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4291
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +997
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +314
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +297
Cntrct_clsr.WebForm1.GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\Cntrct_clsr\Cntrct_clsr\WebForm1.aspx.cs:108
System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) +128
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +808
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +917
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +92
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +97
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +120
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +272
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1696
|
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4330.0
namespace Cntrct_clsr
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
{
Label Sr_no = GridView1.Rows[e.RowIndex].FindControl("lbl_ID") as Label;
TextBox tm_ext_upto_dt = GridView1.Rows[e.RowIndex].FindControl("txt_tm_ext_upto_dt") as TextBox;
TextBox cntrt_cls_trgt_dt = GridView1.Rows[e.RowIndex].FindControl("txt_cntrt_cls_trgt_dt") as TextBox;
TextBox cntrt_cls_dt = GridView1.Rows[e.RowIndex].FindControl("txt_cntrt_cls_dt") as TextBox;
string DropDownList1 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList1") as DropDownList).SelectedItem.Value;
string DropDownList2 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList2") as DropDownList).SelectedItem.Value;
string DropDownList3 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList3") as DropDownList).SelectedItem.Value;
string DropDownList4 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList4") as DropDownList).SelectedItem.Value;
string DropDownList5 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList5") as DropDownList).SelectedItem.Value;
string DropDownList6 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList6") as DropDownList).SelectedItem.Value;
string DropDownList7 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList7") as DropDownList).SelectedItem.Value;
string DropDownList8 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList8") as DropDownList).SelectedItem.Value;
string DropDownList9 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList9") as DropDownList).SelectedItem.Value;
string DropDownList10 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList10") as DropDownList).SelectedItem.Value;
string DropDownList11 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList11") as DropDownList).SelectedItem.Value;
string DropDownList12 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList12") as DropDownList).SelectedItem.Value;
string DropDownList13 = (GridView1.Rows[e.RowIndex].FindControl("DropDownList13") as DropDownList).SelectedItem.Value;
TextBox rmrk = GridView1.Rows[e.RowIndex].FindControl("rmrk") as TextBox;
con = new SqlConnection(cs);
con.Open();
SqlCommand cmd = new SqlCommand("Update cntrct_clsr set tm_ext_upto_dt='" + tm_ext_upto_dt.Text + "',cntrt_cls_trgt_dt='" + cntrt_cls_trgt_dt.Text + "',cntrt_cls_dt='" + cntrt_cls_dt.Text + "',ccp_one='" + DropDownList1 + "',ccp_two='" + DropDownList2 + "',ccp_three='" + DropDownList3 + "' ,ccp_four='" + DropDownList4 + "',ccp_five='" + DropDownList5 + "',ccp_six='" + DropDownList6 + "',ccp_seve='" + DropDownList7 + "',ccp_eight='" + DropDownList8 + "',ccp_nine='" + DropDownList9 + "',ccp_ten='" + DropDownList10 + "',ccp_ele='" + DropDownList11 + "',ccp_tw='" + DropDownList12 + "',ccp_thre='" + DropDownList13 + "',rmrk='" + rmrk.Text + "' where Sr_no=" + Convert.ToInt32(Sr_no.Text), con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
ShowData();
Calendar cal = GridView1.Rows[e.RowIndex].FindControl("Calendar1") as Calendar;
}
}
}