Trying to Take Data from One BO to Another (Not the Same Structure)


Author
Message
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I will try a simple maintenance form. That is a good idea. I recreated the entire project and I am still getting the same error but I will try the maintenance form now and see what that brings. I'll be back.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'd also double check the designer file of the BO. Check the TableName property, check the field name properties (the ones that list the field names in the BO). (Or just do a partial rebuild...then you'll know that the BO matches.)



The BO doesn't have to have the same structure as the table, but you then need to set the exclude on insert and exclude on update properties (can't recall exact names) because the BO will use all the mapped fields when it creates the SQL to do an update or insert and if the structure doesn't match, you need to exclude those fields that aren't actually used. However, because you're having trouble with the PK, I'm thinking something else is going on.



Likely, you're best bet is to attempt to make a sample app that reproduces the issue. Start with a simple maintenance form using the BO and confirm that the BO will load, save, insert, delete data into the table. If that works, then move on to a grid (maybe try a plain vanilla .NET grid first). If that works, move on to the copying of data from one BO to another. I can't tell you how many times I've had a thorny issue that got resolved by following a process like this.
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
The BO's don't have to have the same structure do they? TIA.
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
The BO mapper Shows all the fields and the fields are found in the Database Table so is there somewhere else I should check? Does the PK have to be defaulted to -1?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
It is a bit hard to say what is going on, but an Invalid Column name error usually indicates that the underlying SQL table doesn't have that column within it. The ContestantsProRodeoBO was mapped against the right table? I.e. that that table has the SubjectToWithHolding, and EventBB, etc. columns? I would seem that you did a partial build of the BO, since it appears that you have the strong typed properties. But since it is also complaining about the PK for the table, it sure seems like the BO and the underlying database aren't in synch. I'd double check that first (check tablename, columns etc with db table/columns).
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
The Code That causes the Problem is:





If Me.ContestantsPRCABO1.MoveFirst Then

Dim howmany As Integer

howmany = Me.ContestantsPRCABO1.Count

MessageBox.Show(howmany.ToString, "Number of contestants")

Dim cnt As Integer

For cnt = 1 To howmany

Me.ContestantsProRodeoBO1.NewRow()



Me.ContestantsProRodeoBO1.RodeoID = Me.ContestantsPRCABO1.rodeoId

Me.ContestantsProRodeoBO1.MembershipCD = Me.ContestantsPRCABO1.membershipCD

Me.ContestantsProRodeoBO1.MembershipNumber = Me.ContestantsPRCABO1.membershipNumber

Me.ContestantsProRodeoBO1.Nationality = Me.ContestantsPRCABO1.nationality

...............

Me.ContestantsProRodeoBO1.Fee = 0

Me.ContestantsProRodeoBO1.EventBB = String.Empty

Me.ContestantsProRodeoBO1.EventBR = ""

Me.ContestantsProRodeoBO1.EventGB = ""

Me.ContestantsProRodeoBO1.EventRB = ""

Me.ContestantsProRodeoBO1.EventSB = ""

Me.ContestantsProRodeoBO1.EventSR = ""

Me.ContestantsProRodeoBO1.EventSW = ""

Me.ContestantsProRodeoBO1.EventTD = ""

Me.ContestantsProRodeoBO1.EventTR = ""

Me.ContestantsProRodeoBO1.Save()



Next



End If





The Lines above the ................... work fine but the ones below Do Not. ????



In the New Table(where the data is going) I have contraints like the following:



ALTER TABLE [dbo].[Contestants] ADD CONSTRAINT [DF_Contestants_EventBB] DEFAULT ('') FOR [EventBB]



ALTER TABLE [dbo].[Contestants] ADD CONSTRAINT [DF_Contestants_SubjectToWithHolding] DEFAULT ((0)) FOR [SubjectToWithHolding]



CONSTRAINT [PK_Contestants] PRIMARY KEY CLUSTERED

([ContPK] ASC

)



The Error I get is a lengthy one:





MicroFour.StrataFrame.Data.DataLayerSavingException was unhandled by user code

Message="Invalid column name 'SubjectToWithHolding'. Invalid column name 'EventBB'. Invalid column name 'EventBR'. Invalid column name 'EventGB'. Invalid column name 'EventRB'. Invalid column name 'EventSB'. Invalid column name 'EventSR'. Invalid column name 'EventSW'. Invalid column name 'EventTD'. Invalid column name 'EventTR'. Invalid column name 'Fee'. Invalid column name 'ContPK'. Invalid column name 'ContPK'."

Source="MicroFour StrataFrame Business"

StackTrace:

at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.Data.DataLayer.Save(DataTable TableToSave, Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.Business.BusinessLayer.Save()

at DevExpressGridTwoDataBasesSF.Form1.Button3_Click(Object sender, EventArgs e) in C:\VSProjects\DevExpressGridTwoDataBasesSF\DevExpressGridTwoDataBasesSF\Form1.vb:line 53

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.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)

InnerException: System.Data.SqlClient.SqlException

Class=16

ErrorCode=-2146232060

LineNumber=1

Message="Invalid column name 'SubjectToWithHolding'. Invalid column name 'EventBB'. Invalid column name 'EventBR'. Invalid column name 'EventGB'. Invalid column name 'EventRB'. Invalid column name 'EventSB'. Invalid column name 'EventSR'. Invalid column name 'EventSW'. Invalid column name 'EventTD'. Invalid column name 'EventTR'. Invalid column name 'Fee'. Invalid column name 'ContPK'. Invalid column name 'ContPK'."

Number=207

Procedure=""

Server=".\sqlexpress"

Source=".Net SqlClient Data Provider"

State=1

StackTrace:

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(CommandBehavior behavior)

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)

InnerException:





Any help would be greatly Appreciated. TIA.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search