none
Erro Inserir dados no FormView1 RRS feed

  • Pergunta

  • Quando edito meu formview1 e salvo os dados não da erro.

    Mas quando eu vou inserir dados novos da esse erro:

    Server Error in '/' Application.

    Incorrect syntax near '@DATE'.

    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: Incorrect syntax near '@DATE'.

    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:
    [SqlException (0x80131904): Incorrect syntax near '@DATE'.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2073486
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064444
       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.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +215
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +987
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +178
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +394
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +407
       System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +89
       System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation) +377
       System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +612
       System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +112
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
       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
    

    segunda-feira, 18 de junho de 2012 12:28

Respostas

  • Paulo reveja seu select ele deve estar trazendo um campo data inválido, verifique junto ao seu banco se esse campo permite null se permitir no se select altere assim

    select isnull(campodata,'01/01/1900') as campodata ou coloque uma data padrão para esses casos ou coloque '' para sair branco o problema que ele estra trazendo null e qdo vc vai montar seu formview ele apresenta o erro. 


    Junior

    • Marcado como Resposta ricardoti2012 segunda-feira, 18 de junho de 2012 13:28
    segunda-feira, 18 de junho de 2012 13:20