StrataFrame Forum

Bug : When you update a row using stored procedure

http://forum.strataframe.net/Topic13174.aspx

By Alagarsamy Rajamannar - 12/27/2007

Hi,

 I found this problem when I am developing an application for my client. Initialy I thought I am making mistake. I checked the forums. I couldn't find any usefull information. But I found a sql script in the forum that explains how to use stored procedures. Using the same tables and stored procedure I created a separate test application that has one business object which maps to table  CrudTest_GuidPk.

I wanted use  sp_CrudTest_Insert_GuidPk and sp_CrudTest_Update_GuidPk for inserting and updating respectively.

I tested the above stored procedures separately outside the application. I am able insert and update the table.

I set appropriate properties:

InsertStoredProcedureName = sp_CrudTest_Insert_GuidPk

InsertUsingStoredProcedure=true

PrimaryKeyIsAutoIncremented = false

StoredProcedureParameterPreFix =@

UpdateConcurrencyType = Off

UpdateStoredProcedureName = sp_CrudTest_Update_GuidPk

UpdateUsingStoredProcedureName= true

I am able to Insert a row through application but whn I try edit and save I am getting the following error:

BusinessLayerException
  An error occurred while saving an the data to the server.
DataLayerSavingException
  Procedure or function sp_CrudTest_Update_GuidPk has too many arguments specified.
SqlException
  Procedure or function sp_CrudTest_Update_GuidPk has too many arguments specified.

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.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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteNonQuery(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.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.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)

I am able to re-create the problem several times in different applications.

Please help

By Alagarsamy Rajamannar - 12/27/2007

I have attached the debug html file also.

It adds _ORGPK PARAMETER by its own. What does that mean?

Is it a fetaure or Am I missing something here?

Please help me...

By Greg McGuffey - 12/27/2007

I don't believe you have built your sproc correctly. See the "Table CRUD Stored Procedures" topic in help to figure you how to build your sprocs to work with SF. Also just note what parameters are passed in the debug file. It looks like when using a GUID, you need the last param to be another GUID (not sure why). I hope that helps some.




By Alagarsamy Rajamannar - 12/28/2007

I LOOKED AT OLD REPLIES DONE SF.

BY DEFAULT IF WE HAVE NON-IDENTITY COLUMN ACTING AS PRIMARY KEY IN THIS CASE GUID WHICH IS NON-IDENTITY COLUMN  UPDATE / INSERT STORED PROCEDURE NEEDS TO HAVE <columnname>_ORGPK AS INPUT PARAMETER

HIYA....I FOUND THIS

By Greg McGuffey - 12/28/2007

Excellent! BigGrin