﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Trying to Take Data from One BO to Another (Not the Same Structure)</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 23 May 2026 06:24:22 GMT</lastBuildDate><ttl>20</ttl><item><title>Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24795.aspx</link><description>The Code That causes the Problem is:&lt;br&gt;
&lt;br&gt;
[codesnippet]&lt;br&gt;
      If Me.ContestantsPRCABO1.MoveFirst Then&lt;br&gt;
         Dim howmany As Integer&lt;br&gt;
         howmany = Me.ContestantsPRCABO1.Count&lt;br&gt;
         MessageBox.Show(howmany.ToString, "Number of contestants")&lt;br&gt;
         Dim cnt As Integer&lt;br&gt;
         For cnt = 1 To howmany&lt;br&gt;
            Me.ContestantsProRodeoBO1.NewRow()&lt;br&gt;
&lt;br&gt;
            Me.ContestantsProRodeoBO1.RodeoID = Me.ContestantsPRCABO1.rodeoId&lt;br&gt;
            Me.ContestantsProRodeoBO1.MembershipCD = Me.ContestantsPRCABO1.membershipCD&lt;br&gt;
            Me.ContestantsProRodeoBO1.MembershipNumber = Me.ContestantsPRCABO1.membershipNumber&lt;br&gt;
            Me.ContestantsProRodeoBO1.Nationality = Me.ContestantsPRCABO1.nationality&lt;br&gt;
...............&lt;br&gt;
            Me.ContestantsProRodeoBO1.Fee = 0&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventBB = String.Empty&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventBR = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventGB = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventRB = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventSB = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventSR = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventSW = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventTD = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.EventTR = ""&lt;br&gt;
            Me.ContestantsProRodeoBO1.Save()&lt;br&gt;
&lt;br&gt;
         Next&lt;br&gt;
&lt;br&gt;
      End If&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
The Lines above the ................... work fine but the ones below Do Not. ????&lt;br&gt;
&lt;br&gt;
In the New Table(where the data is going) I have contraints like the following:&lt;br&gt;
&lt;br&gt;
ALTER TABLE [dbo].[Contestants] ADD  CONSTRAINT [DF_Contestants_EventBB]  DEFAULT ('') FOR [EventBB]&lt;br&gt;
&lt;br&gt;
ALTER TABLE [dbo].[Contestants] ADD  CONSTRAINT [DF_Contestants_SubjectToWithHolding]  DEFAULT ((0)) FOR [SubjectToWithHolding]&lt;br&gt;
&lt;br&gt;
CONSTRAINT [PK_Contestants] PRIMARY KEY CLUSTERED &lt;br&gt;
([ContPK] ASC&lt;br&gt;
)&lt;br&gt;
&lt;br&gt;
The Error I get is a lengthy one:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
MicroFour.StrataFrame.Data.DataLayerSavingException was unhandled by user code&lt;br&gt;
  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'."&lt;br&gt;
  Source="MicroFour StrataFrame Business"&lt;br&gt;
  StackTrace:&lt;br&gt;
       at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey)&lt;br&gt;
       at MicroFour.StrataFrame.Data.DataLayer.Save(DataTable TableToSave, Boolean Transactional, String TransactionKey)&lt;br&gt;
       at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)&lt;br&gt;
       at MicroFour.StrataFrame.Business.BusinessLayer.Save()&lt;br&gt;
       at DevExpressGridTwoDataBasesSF.Form1.Button3_Click(Object sender, EventArgs e) in C:\VSProjects\DevExpressGridTwoDataBasesSF\DevExpressGridTwoDataBasesSF\Form1.vb:line 53&lt;br&gt;
       at System.Windows.Forms.Control.OnClick(EventArgs e)&lt;br&gt;
       at System.Windows.Forms.Button.OnClick(EventArgs e)&lt;br&gt;
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)&lt;br&gt;
       at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)&lt;br&gt;
       at System.Windows.Forms.Control.WndProc(Message&amp; m)&lt;br&gt;
       at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)&lt;br&gt;
       at System.Windows.Forms.Button.WndProc(Message&amp; m)&lt;br&gt;
       at System.Windows.Forms.Control.ControlNative&amp;#119;indow.OnMessage(Message&amp; m)&lt;br&gt;
       at System.Windows.Forms.Control.ControlNative&amp;#119;indow.WndProc(Message&amp; m)&lt;br&gt;
       at System.Windows.Forms.Native&amp;#119;indow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)&lt;br&gt;
  InnerException: System.Data.SqlClient.SqlException&lt;br&gt;
       Class=16&lt;br&gt;
       ErrorCode=-2146232060&lt;br&gt;
       LineNumber=1&lt;br&gt;
       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'."&lt;br&gt;
       Number=207&lt;br&gt;
       Procedure=""&lt;br&gt;
       Server=".\sqlexpress"&lt;br&gt;
       Source=".Net SqlClient Data Provider"&lt;br&gt;
       State=1&lt;br&gt;
       StackTrace:&lt;br&gt;
            at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)&lt;br&gt;
            at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)&lt;br&gt;
            at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)&lt;br&gt;
            at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)&lt;br&gt;
            at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()&lt;br&gt;
            at System.Data.SqlClient.SqlDataReader.get_MetaData()&lt;br&gt;
            at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)&lt;br&gt;
            at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)&lt;br&gt;
            at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)&lt;br&gt;
            at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)&lt;br&gt;
            at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)&lt;br&gt;
            at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)&lt;br&gt;
            at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)&lt;br&gt;
            at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteReader(DbCommand Command, Boolean IsTransactional, String TransactionKey)&lt;br&gt;
            at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)&lt;br&gt;
            at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)&lt;br&gt;
            at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)&lt;br&gt;
       InnerException:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Any help would be greatly Appreciated. TIA.&lt;br&gt;</description><pubDate>Tue, 06 Oct 2009 08:06:59 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24864.aspx</link><description>I will spend a lot of time on this sample. I thank you very much. I know the help file is very good but I just could not find the pieces I needed to get thru this. &lt;br&gt;
This forum is such a great place. Thank you all for hanging in there with me........&lt;br&gt;</description><pubDate>Tue, 06 Oct 2009 08:06:59 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24863.aspx</link><description>Hi Terry,&lt;br&gt;
&lt;br&gt;
Here is a working project with not DevExpress grids, just regular datagridviews.  &lt;br&gt;
&lt;br&gt;
Here are some quick things to look at:&lt;br&gt;
&lt;br&gt;
1.- AppMain.SetDataSources:&lt;br&gt;
     When using more than one database, you must setup the connection for each database and use the ConnectionManager.ApplicationKey and BO.DataSourceKey to properly identify each connection and database.&lt;br&gt;
&lt;br&gt;
2.- Business Object:&lt;br&gt;
     In your case, you must set the DataSourceKey for each BO.&lt;br&gt;
&lt;br&gt;
3.- In the Form:&lt;br&gt;
     You must load the data for ContestantsPRCABO1.  check the code in the form.Load.&lt;br&gt;
&lt;br&gt;
     Since the data structure of both tables are not 100% equal, then don't use the BO.CopyDataFrom(), instead loop each record, assign the values, and since your Schema for the Rodeo database have NOT NULL like Greg pointed out before, you MUST assign a default value, or you will get errors when inserting records.&lt;br&gt;
&lt;br&gt;
Keep in mind that this process will not check for duplicate records, so whenever you run it, it will insert a bunch of records again.&lt;br&gt;
&lt;br&gt;
There is a lot to learn from this process, to avoid future frustration, you must take some time to dig deeper into the SF help file and the forum posts, all techniques I showed here in your project are well explain in both resources.&lt;br&gt;
&lt;br&gt;
Good luck!</description><pubDate>Mon, 05 Oct 2009 23:21:41 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24862.aspx</link><description>I got and I also reproduced the error.  There are couple of thing missing about setting up the BOs connection to different databases.  Will post working sample soon.</description><pubDate>Mon, 05 Oct 2009 22:49:33 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24861.aspx</link><description>The ContestantsPRCABO is connected to the secretarysystem database and the ContestantsRodeoBO is connected to the Rodeo Database.</description><pubDate>Mon, 05 Oct 2009 22:46:31 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24860.aspx</link><description>Terry,&lt;br&gt;
&lt;br&gt;
You have 2 BOs and 2 Databases, and in the AppMain.vb only one connection.  &lt;br&gt;
&lt;br&gt;
Which BO is connected to witch database?</description><pubDate>Mon, 05 Oct 2009 22:01:57 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24859.aspx</link><description>Edhy if you can see the grid you can delete it since I just had it on the form to see the original data but the data loads when the form loads so it really is not needed.</description><pubDate>Mon, 05 Oct 2009 21:47:58 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24858.aspx</link><description>Sorry Terry, I don't have devExpress so I will not be able to test your sample project.</description><pubDate>Mon, 05 Oct 2009 17:09:49 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24857.aspx</link><description>The two databases are secretarysystem and rodeo with secretarysystem.dbo.contestants having the data I want into rodeo.dbo.contestants.&lt;br&gt;
&lt;br&gt;
The Visualstudio 2008 project is: DevExpressGridTwoDatabasesSF.&lt;br&gt;
&lt;br&gt;</description><pubDate>Mon, 05 Oct 2009 16:32:58 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24850.aspx</link><description>Terry,&lt;br&gt;
&lt;br&gt;
What I meant for you to post was an actual sample.  We can bounce back and forth another 30 posts.  This thread has gotten really long since you started it and you still do not have an answer.&lt;br&gt;
&lt;br&gt;
If you can post a sample so that we do not have to try and get all of your structures and development environment in our heads without being able to actually see it, you will get some answers much more quickly.&lt;br&gt;
&lt;br&gt;
This is a policy that we use even internally when we run into things.  It helps lower the frustration level on all parties and the ultimate goal is helping you find an answer...but all of our standard suggestion have not seemed to help. &lt;br&gt;
&lt;br&gt;
If you need to post an mdf of SQL backup and a small sample, not your actual full application, but a sample app with BOs that reproduces the issue, that should be your next step.  Thanks.</description><pubDate>Mon, 05 Oct 2009 15:17:19 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24844.aspx</link><description>Boy, there a lot of NOT NULLs in the target table  :blink:&lt;br&gt;
&lt;br&gt;
I think the SetDefaultValues is going to be your friend (either handle this within ContestantsRodeoBO itself, or add handlers in the form/code that is doing this work on the SetDefaultValues event of ContestantsRodeoBO1). You need to set default values for all the columns in the target table that won't be filled in.  Usually when you use the BO to add a new row, it will deal with the PK automatically. Otherwise you'll have to deal with that as well.</description><pubDate>Mon, 05 Oct 2009 10:55:24 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24841.aspx</link><description>This is the structure of the BO that Has Data:&lt;br&gt;
CREATE TABLE [dbo].[Contestants](&lt;br&gt;
[rodeoId] [int] NOT NULL,&lt;br&gt;
[membershipCD] [char](1) NOT NULL,&lt;br&gt;
[membershipNumber] [int] NOT NULL,&lt;br&gt;
[contestantName] [varchar](50) NOT NULL,&lt;br&gt;
[invertedName] [varchar](50) NOT NULL,&lt;br&gt;
[city] [varchar](30) NULL,&lt;br&gt;
[state] [varchar](10) NULL,&lt;br&gt;
[creditCD] [char](1) NULL,&lt;br&gt;
[circuitCD] [char](3) NULL,&lt;br&gt;
[contestantId] [int] NOT NULL,&lt;br&gt;
[subjectToWithholdings] [bit] NULL,&lt;br&gt;
[nationality] [varchar](50) NULL,&lt;br&gt;
[contestantGivenName] [varchar](50) NULL,&lt;br&gt;
[contestantNumber] [int] NULL,&lt;br&gt;
&lt;br&gt;
This is the Structure of the BO I want to Copy the Data TO and Save:&lt;br&gt;
CREATE TABLE [dbo].[Contestants](&lt;br&gt;
[ContPK] [int] IDENTITY(1,1) NOT NULL,     This is My Primary Key&lt;br&gt;
[RodeoID] [int] NOT NULL,&lt;br&gt;
[MembershipCD] [char](1) NOT NULL,&lt;br&gt;
[MembershipNumber] [int] NOT NULL,&lt;br&gt;
[ContestantID] [int] NOT NULL,&lt;br&gt;
[ContestantNumber] [int] NOT NULL,&lt;br&gt;
[ContestantName] [varchar](50) NOT NULL,&lt;br&gt;
[InvertedName] [varchar](50) NOT NULL,&lt;br&gt;
[ContestantGivenName] [varchar](50) NOT NULL,&lt;br&gt;
[City] [varchar](30) NOT NULL,&lt;br&gt;
[State] [varchar](10) NOT NULL,&lt;br&gt;
[CreditCD] [char](1) NOT NULL,&lt;br&gt;
[CircuitCD] [char](3) NOT NULL,&lt;br&gt;
[SubjectToWithHolding] [bit] NOT NULL,&lt;br&gt;
[Nationality] [varchar](50) NOT NULL,&lt;br&gt;
[EventBB] [char](2) NOT NULL,&lt;br&gt;
[EventBR] [char](2) NOT NULL,&lt;br&gt;
[EventGB] [char](2) NOT NULL,&lt;br&gt;
[EventRB] [char](2) NOT NULL,&lt;br&gt;
[EventSB] [char](2) NOT NULL,&lt;br&gt;
[EventSR] [char](2) NOT NULL,&lt;br&gt;
[EventSW] [char](2) NOT NULL,&lt;br&gt;
[EventTD] [char](2) NOT NULL,&lt;br&gt;
[EventTR] [char](2) NOT NULL,&lt;br&gt;
[Fee] [numeric](9, 2) NOT NULL,&lt;br&gt;
&lt;br&gt;
Now when I copy the data since the contpk is not in the original table it does not show up in the RodeoBO. Since it is my PK the Save does not work or at least that is the way I understand it. If you need more info please let me know. Thanks for your help.&lt;br&gt;</description><pubDate>Mon, 05 Oct 2009 10:16:33 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24840.aspx</link><description>Terry,&lt;/P&gt;&lt;P&gt;I have been away for a while and as you have noticed haven't been out here. But I think that this is getting way more complicated that it needs to be.&lt;/P&gt;&lt;P&gt;First, from what I understand, you have two different BO structures and are trying to pass the data from one into the other.&amp;nbsp; Is this correct?&lt;/P&gt;&lt;P&gt;Second, moving data between BOs is actually something that can be done easily and there are a few gotchas if the structure are different and you are trying to save.&amp;nbsp; For example the BO has the AllFieldsList which is used by the BO when saving a record so it knows how to produce the UPDATE, etc.&amp;nbsp; If you have columns that do not exist within the BO but are expected, then you would want to use the ExcludeFieldsFromUpdate/Insert on the BO to prevent the BO from trying to save column values that are not there.&lt;/P&gt;&lt;P&gt;Finally, if this doesn't get you going, the I recommend created a quick sample showing what you are trying to do so that there is no guess work as it will help you get an answer more quickly.</description><pubDate>Mon, 05 Oct 2009 09:39:05 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24839.aspx</link><description>You might try using the SetDefaultValues event to get the work done.  You might have to add a property to the ContestantsRodeoBO so it knows when to use this.  I got busy and haven't been following this completely, so I might be way off...</description><pubDate>Mon, 05 Oct 2009 09:28:57 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24838.aspx</link><description>You can setup a Bo without a primary key. Look in the help file or the forums for samples. I am not in the office today.</description><pubDate>Mon, 05 Oct 2009 08:16:14 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24837.aspx</link><description>The ContestantsRodeoBO does have a PK in the database and it shows up in the Business Object Mapper called contpk. The ContestantsPRCABO does not have this field in it at all since it does not use a PK. I did not design it I just have to use it. So when the data gets copied no contpk field shows up in the ContestantsRodeoBO1 and therefore I can not set up a loop to fill it with -1. ?&lt;br&gt;</description><pubDate>Mon, 05 Oct 2009 08:00:43 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24835.aspx</link><description>[quote][b]Terry Bottorff (10/04/2009)[/b][hr]&lt;br&gt;
I tried the above code and I get the following error:&lt;br&gt;
&lt;br&gt;
Cannot create INSERT command because the updating DataTable does not contain columns for all PrimaryKeyFields.&lt;br&gt;
&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
Ok, lets clear up some things: ContestantsRodeoBO does have a PK field, but it is not the same as the ContestantsPRCABO1 pk field, right?&lt;br&gt;
&lt;br&gt;
If so, when you copied the data, in the visualizer what is the value of the ContestantsRodeoBO PK field?, it should be -1, if not, then in the for..next loop, just set the value of the PK field to -1 and try again.</description><pubDate>Sun, 04 Oct 2009 22:22:01 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24834.aspx</link><description>[codesnippet]&lt;br&gt;
 For Each contestantsBO As ContestantsRodeoBO In Me.ContestantsRodeoBO1.GetEnumerable()&lt;br&gt;
            '-- Change the CurrentRow state to make sure the record will be saved in the Activation process.&lt;br&gt;
            If contestantsBO.CurrentRow.RowState = Data.DataRowState.Unchanged Then&lt;br&gt;
               'contestantsBO.CurrentRow.SetModified()&lt;br&gt;
               contestantsBO.CurrentRow.SetAdded()&lt;br&gt;
            End If&lt;br&gt;
&lt;br&gt;
         Next&lt;br&gt;
&lt;br&gt;
         If Me.ContestantsRodeoBO1.IsDirty Then&lt;br&gt;
            Me.ContestantsRodeoBO1.Save()&lt;br&gt;
         End If&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
I tried the above code and I get the following error:&lt;br&gt;
&lt;br&gt;
Cannot create INSERT command because the updating DataTable does not contain columns for all PrimaryKeyFields.&lt;br&gt;
&lt;br&gt;</description><pubDate>Sun, 04 Oct 2009 22:07:40 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24829.aspx</link><description>[quote][b]Terry Bottorff (10/04/2009)[/b][hr]Well Edhy with your new code(Data.DataRowState.Unchange )&lt;br&gt;
Cannot create UPDATE command because the updating DataTable does not contain columns for all PrimaryKeyFields.&lt;br&gt;
&lt;br&gt;
Of course since the ContPK was not copied I  know I need to somehow add it too the BO..[/quote]&lt;br&gt;
&lt;br&gt;
Yes your contestantsBO must have the ContPK field so it will be properly updated.&lt;br&gt;</description><pubDate>Sun, 04 Oct 2009 17:44:42 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24828.aspx</link><description>Try this:&lt;br&gt;
&lt;br&gt;
Just change: contestantsBO.CurrentRow.SetModified()&lt;br&gt;
&lt;br&gt;
With contestantsBO.CurrentRow.SetAdded()&lt;br&gt;
&lt;br&gt;
That should trigger an "Insert command instead of Update"&lt;br&gt;</description><pubDate>Sun, 04 Oct 2009 17:41:14 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24827.aspx</link><description>Well Edhy with your new code(Data.DataRowState.Unchange ) I now get this error which I think is a great improvement.&lt;br&gt;
&lt;br&gt;
Cannot create UPDATE command because the updating DataTable does not contain columns for all PrimaryKeyFields.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Of course since the ContPK was not copied I  know I need to somehow add it too the BO. In your previous reply you mentioned "you may need to use Data.DataRowState.Added" but I can not seem to find any examples of just how that would work. Is there a sample somewhere???? TIA. &lt;br&gt;
&lt;br&gt;
I may just be using the wrong search words to find an example. TIA.....</description><pubDate>Sun, 04 Oct 2009 17:31:33 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24826.aspx</link><description>Nope, it does not.&lt;br&gt;
&lt;br&gt;
Did you try it?</description><pubDate>Sun, 04 Oct 2009 17:25:42 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24825.aspx</link><description>Does it make a difference that one BO is coming from one database and the other BO is in another database?</description><pubDate>Sun, 04 Oct 2009 17:17:29 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24824.aspx</link><description>Also you may need to play with the value needed for each RowState, in my sample before I am using Data.DataRowState.Unchange but you may need to use Data.DataRowState.Added so your ContPK gets updated with a new autoincrement value.&lt;br&gt;
&lt;br&gt;</description><pubDate>Sun, 04 Oct 2009 16:26:13 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Trying to Take Data from One BO to Another (Not the Same Structure)</title><link>http://forum.strataframe.net/FindPost24823.aspx</link><description>[quote][b]Terry Bottorff (10/04/2009)[/b][hr]I'm at a lost as to what to do??? TIA.[/quote]&lt;br&gt;
&lt;br&gt;
Don't worry, this is part of the learning curve. :D&lt;br&gt;
&lt;br&gt;
I believe the problem is that the CopyDataFrom does not keep the RowState so you will have to loop one more time in the copied BO and change the RowState for all the records, so the Save() can actually save them.  Something like this could do the trick:&lt;br&gt;
[quote]&lt;br&gt;
        If Me.ContestantsPRCABO1.Count &gt; 0 Then&lt;br&gt;
            '-- Copy data to Me.ContestantsRodeoBO1&lt;br&gt;
            Me.ContestantsRodeoBO1.CopyDataFrom(Me.ContestantsPRCABO1, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)&lt;br&gt;
&lt;br&gt;
            '-- Loop the Me.ContestantsRodeoBO1 and change the RowState if needed&lt;br&gt;
            For Each contestantsBO As ContestantsRodeoBO In Me.ContestantsRodeoBO1.GetEnumerable()&lt;br&gt;
                '-- Change the CurrentRow state to make sure the record will be saved in the Activation process.&lt;br&gt;
                If contestantsBO.CurrentRow.RowState = Data.DataRowState.Unchanged Then&lt;br&gt;
                    contestantsBO.CurrentRow.SetModified()&lt;br&gt;
                End If&lt;br&gt;
            Next&lt;br&gt;
&lt;br&gt;
            '-- Save the Record&lt;br&gt;
            If Me.ContestantsRodeoBO1.IsDirty Then&lt;br&gt;
                Me.ContestantsRodeoBO1.Save()&lt;br&gt;
            End If&lt;br&gt;
        End If&lt;br&gt;
[/quote]</description><pubDate>Sun, 04 Oct 2009 16:20:53 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>