0

当我单击一个按钮,将数据存储在远程 sql 数据库中时,它一直给我这个错误,即使我删除了datetime数据库中的类型表。

该表现在也可以为空,但让我感到困惑的是,我并没有真正将任何内容存储到该datetime表中,我真的不知道该怎么想。

这是错误的堆栈跟踪:

Error de servidor en la aplicación '/'.

Desbordamiento de SqlDateTime. Debe estar entre 1/1/1753 12:00:00 AM y 12/31/9999 11:59:59 PM.

Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código. 

Detalles de la excepción: System.Data.SqlTypes.SqlTypeException: Desbordamiento de SqlDateTime. Debe estar entre 1/1/1753 12:00:00 AM y 12/31/9999 11:59:59 PM.

Error de código fuente: 


Línea 23:             db.Usuario_Web.InsertOnSubmit(columna);
Línea 24:             //Sumbit changes to the database
Línea 25:             db.SubmitChanges();
Línea 26:         }
Línea 27: 

Archivo de origen: c:\Users\Kristian\Documents\zulcon\Grupo Zulcon\Grupo Zulcon\Botones.cs    Línea: 25 

Seguimiento de la pila: 


[SqlTypeException: Desbordamiento de SqlDateTime. Debe estar entre 1/1/1753 12:00:00 AM y 12/31/9999 11:59:59 PM.]
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc, Boolean sync, TaskCompletionSource`1 completion, Int32 startRpc, Int32 startParam) +5635
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +1325
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +175
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +134
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.ExecuteReader() +12
System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +1306
System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +118
  System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +342
System.Data.Linq.StandardChangeDirector.DynamicInsert(TrackedObject item) +145
System.Data.Linq.StandardChangeDirector.Insert(TrackedObject item) +215
System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +378
System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +372
System.Data.Linq.DataContext.SubmitChanges() +23
Grupo_Zulcon.Botones.SaveCVInfo2(String varOne, String varTwo, String varThree) in c:\Users\Kristian\Documents\zulcon\Grupo Zulcon\Grupo Zulcon\Botones.cs:25
Grupo_Zulcon.EnvianosTuCurriculum.Button1_Click(Object sender, EventArgs e) in c:\Users\Kristian\Documents\zulcon\Grupo Zulcon\Grupo Zulcon\EnvianosTuCurriculum.aspx.cs:32
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553594
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
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) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

这就是我在按钮中引用的内容:

 public void SaveCVInfo2(string varOne,string varTwo, string  varThree)
{
    using (ConexionGeneralDataContext db = new ConexionGeneralDataContext())
    {
        Usuario_Web columna = new Usuario_Web();
        //Add new values to each fields
        columna.Nombre = varOne;
        columna.Apellido = varTwo;
        columna.Em_solicitado = varThree;
        //and the rest where the textboxes would have been


        //Insert the new Customer object
        db.Usuario_Web.InsertOnSubmit(columna);
        //Sumbit changes to the database
        db.SubmitChanges();
    }

}

任何人都可以对此有所了解吗?

用英语编辑堆栈跟踪:

Server Error in '/' Application .

SqlDateTime overflow . Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Description : An unhandled exception when running the current Web request . Check the stack trace for more information about the error and where it originated in the code.

Exception Details : System.Data.SqlTypes.SqlTypeException : SqlDateTime overflow . Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM .

Source Error :


Line 23 : db.Usuario_Web.InsertOnSubmit (column) ;
Line 24 : / / Sumbit changes to the database
Line 25 : db.SubmitChanges ();
Line 26 : }
Line 27 :

Source File: c: \ Users \ Kristian \ Documents \ zulcon \ Group Zulcon \ Group Zulcon \ Botones.cs Line : 25

Stack Trace :


[ SqlTypeException : SqlDateTime overflow . Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM . ]
System.Data.SqlClient.TdsParser.TdsExecuteRPC ( _SqlRPC [ ] rpcArray , Int32 timeout , Boolean inSchema , SqlNotificationRequest notificationRequest , TdsParserStateObject stateObj , Boolean isCommandProc , Boolean sync, TaskCompletionSource ` 1 completion , startRpc Int32 , Int32 startParam ) +5635
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds ( CommandBehavior cmdBehavior , RunBehavior runBehavior , Boolean returnStream , Boolean async , Int32 timeout , Task & task , Boolean asyncWrite ) +1325
System.Data.SqlClient.SqlCommand.RunExecuteReader ( CommandBehavior cmdBehavior , RunBehavior runBehavior , Boolean returnStream , String method , TaskCompletionSource ` 1 completion , Int32 timeout , Task & task , Boolean asyncWrite ) +175
System.Data.SqlClient.SqlCommand.RunExecuteReader ( CommandBehavior cmdBehavior , RunBehavior runBehavior , Boolean returnStream , String method) +53
System.Data.SqlClient.SqlCommand.ExecuteReader ( CommandBehavior behavior, String method ) +134
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader ( CommandBehavior behavior ) +41
System.Data.Common.DbCommand.ExecuteReader ( ) +12
System.Data.Linq.SqlClient.SqlProvider.Execute (Expression query , QueryInfo QueryInfo , IObjectReaderFactory factory , Object [ ] parentArgs , Object [ ] userArgs , ICompiledSubQuery [ ] Subqueries , Object LastResult ) died 1306
System.Data.Linq.SqlClient.SqlProvider.ExecuteAll (Expression query , QueryInfo [ ] queryInfos , IObjectReaderFactory factory , Object [ ] userArguments , ICompiledSubQuery [ ] SubQueries ) +118

  

System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute (Expression query) +342
System.Data.Linq.StandardChangeDirector.DynamicInsert ( TrackedObject item) +145
System.Data.Linq.StandardChangeDirector.Insert ( TrackedObject item) +215
System.Data.Linq.ChangeProcessor.SubmitChanges ( ConflictMode failureMode ) +378
System.Data.Linq.DataContext.SubmitChanges ( ConflictMode failureMode ) +372
System.Data.Linq.DataContext.SubmitChanges ( ) +23
Grupo_Zulcon.Botones.SaveCVInfo2 (String Varone , varTwo String , String varThree ) in c: \ Users \ Kristian \ Documents \ zulcon \ Group Zulcon \ Group Zulcon \ Botones.cs : 25
Grupo_Zulcon.EnvianosTuCurriculum.Button1_Click ( Object sender , EventArgs e) in c: \ Users \ Kristian \ Documents \ zulcon \ Group Zulcon \ Group Zulcon \ EnvianosTuCurriculum.aspx.cs : 32
System.Web.UI.WebControls.Button.OnClick ( EventArgs e) +9553594
System.Web.UI.WebControls.Button.RaisePostBackEvent (String eventArgument ) +103
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 ) +35
System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint , Boolean includeStagesAfterAsyncPoint ) +1724
4

1 回答 1

1

看来你的日期有问题。您正在更新的列之一似乎是日期,但您将其作为字符串传递。SQL 会尽力解析此日期,但这可能会导致日期超出范围,从而导致错误。

DateTime.Parse在设置值之前在代码中使用。

如果可能的话,用英语发布错误消息也可能会有所帮助。

于 2013-10-13T11:02:10.583 回答