By Robert Carl Johnson - 6/19/2007
I created a BO and set UpdateConcuranctyType to OptimisticTimeStamp as recommended. Set the field as ReadOnly to see if that helped (it didn't). When adding a record or editing an exiting record and saving the timestamp field is being "updated" and that is what generated the error:
BusinessLayerException
An error occurred while saving an the data to the server.
DataLayerSavingException
Cannot update a timestamp column.
SqlException
Cannot update a timestamp column.
Source : MicroFour StrataFrame Business
Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteReader(DbCommand Command, Boolean IsTransactional, String TransactionKey)
at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)
at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)
at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)
at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()
at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnFormClosing(FormClosingEventArgs e)
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
How do I avoid this? I want to keep my timestamp column in the DB or something simular. I have read the other threads on this and tried the suggestions as far as setting "Return Alternate On Null" with a return value of "Nothing" which generated a VS2005 error.. didn't like the "Nothing". Tried the Date suggestion of "1/1/1800" with no joy either.. didn't like the date.. timestamp is not a date.. ( I knew that going in but it was worth a try.. lol.. getting a little despriate here...) So, what is left for me to do?
Regards
Robert
|
By Larry Caylor - 6/19/2007
Robert,Did you set the RowVersionOrTimestampColumn property on the BO to the name of the column that contains the SQL timepstamp? -Larry
|
By Robert Carl Johnson - 6/19/2007
To put it succinctly "NUTS!" I didn't see that setting.... So, if I understand you correctly, all I have to do is set this property to bind to my timestamp column and I'm good to go? Do I set this in the Property sheet or is it done in code and if so, where do you suggest, in the BO code or form load code. Seems like BO code would be best. Where in the BO code would you place it and what would it look like? I'm a bit of a newbie here so please bear with me if you would....
Thanks so much for your reply Larry.
Regards,
Robert
|
By Greg McGuffey - 6/19/2007
It is set in the BO mapper, then serialized as code in the designer file. Set only once for a BO, in mapper.
|
By Robert Carl Johnson - 6/19/2007
Thanks. I appreciate your time.
Robert
|
By StrataFrame Team - 6/20/2007
Yeah, you can set the RowVersionOrTimestampColumn within the component designer for your business object. If you right-click the business object within the solution explorer and then choose "View Designer" you can set the property within the property sheet. You'll also want to set your UpdateConcurrencyType property to OptimisticTimestamp.Now, if the timestamp isn't being used for concurrency checking (not sure why you wouldn't, but you never know...) you can add the column's name to the FieldsToExcludeOnInsert and FieldsToExcludeOnUpdate property. That will prevent the BO from trying to send the field to the server (also useful for a column that's an IDENTITY column, but isn't the PK).
|
By Robert Carl Johnson - 6/21/2007
Thank you for that information... just what I needed.
Regards,
Robert
|
By StrataFrame Team - 6/21/2007
Excellent, glad you're getting it going
|
|