StrataFrame Forum

Cant add Business Object to a form

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

By Ger Cannoll - 5/18/2008

Just started to set up test app.

I have created a business object, and added it to an New Project. I've also added a Maintenence Form. Am in the maintenance from and am trying to add the bsuiness object. I have 2 problems:

1. From the Miantenece Form, I click on Toolbox, but cant see a buisness object anywhere to add.

2. If I F5 to compile and run the form, it comes up with a Database Connection Wizard, defaulting to Sql Server and asking me to select a Database. I am not sure what this is for.. The buisness object I have set up is based on a VFP database.

By Rogerio Mauri - 5/18/2008

Olá...

It shows images (PrintScreen) for one better analysis.

By Edhy Rijo - 5/18/2008

Hi Gerard,

1. From the Miantenece Form, I click on Toolbox, but cant see a buisness object anywhere to add.

When working with your BO, you must rebuild the BO's project in order to see it in the toolbox.

2. If I F5 to compile and run the form, it comes up with a Database Connection Wizard, defaulting to Sql Server and asking me to select a Database. I am not sure what this is for.. The buisness object I have set up is based on a VFP database.

I have not tried connecting to VFP tables, but the Connection Wizard will show up whenever a connection is not defined for your project, usually the first time the application is run, you can control this in the AppMain.vb file.

By Ger Cannoll - 5/18/2008

Still cannot see Buisness Object in Toolbox. Where is it supposed to be ? I can see in toolbox, sections Srataframe Controls & components, ANOther Componets, All Windows Forms. Should it be under Strataframe or in a section on its own

Also, I still have no lucj when comiling the test app... its still looking for a databse and I am not sure on what goes in here

By Edhy Rijo - 5/18/2008

Hi Gerarld,

Here are the steps to create a BO:

  1. Create a BO class based on StrataFrame BO class.
  2. Open the Business Object Mapper (BOM)
    • Map your class with your table.
    • In the BOM build the Partial Class for your BO.
    • Close the BOM.
  3. In VS IDE Build your BO project or the whole solution, then open the form and the BO classes will appear in the ToolBox.  In my case I created a Business Object Project Library named IBS_BOL, so it will show in the ToolBox as IBS_BOL Components

By Trent L. Taylor - 5/19/2008

1. From the Miantenece Form, I click on Toolbox, but cant see a buisness object anywhere to add.

They will not appear for 1 of 3 reasons.  1.) Your project that contains the assemblies has not been built. 2.) The business objects that you are trying to include are not in a project within the solution 3.) Your preferences are setup to prevent any custom control from automatically appearing within the toolbox.  You can set this by opening VS and then clicking Tools -> Options -> Windows Forms Designer -> AutoPopulateToolbox

2. If I F5 to compile and run the form, it comes up with a Database Connection Wizard, defaulting to Sql Server and asking me to select a Database. I am not sure what this is for.. The buisness object I have set up is based on a VFP database.

You need to configure your AppMain to either setup the data sources for your application manually, or if you plan to use the Connection Wizard, you will need to setup the required data source items.  By default, the template has an SQLDataSourceItem in this list...so you will need to change this.  You can look through the docs on this as well, but you will want to modify your AppMain, open the SetDataSources method, and then change the AddRequiredDataSource call to meet your needs...or you could just manually set the DataSources, but in either case, you need to setup the data sources for your application.

By Ger Cannoll - 5/20/2008

They will not appear for 1 of 3 reasons.  1.) Your project that contains the assemblies has not been built. 2.) The business objects that you are trying to include are not in a project within the solution 3.) Your preferences are setup to prevent any custom control from automatically appearing within the toolbox.  You can set this by opening VS and then clicking Tools -> Options -> Windows Forms Designer -> AutoPopulateToolbox

Ok. I have created the DLL for business objects and am trying to access these in a separate project. I have gone through creating anew Tab in the toolbox, and added in the business Object Dll.I can now see this in the toolbox, but when I clixk the +, all I get is a Pointer option. I cant see the actual Busines Object .

By Edhy Rijo - 5/21/2008

Hi Gerard,

I believe you have to add a reference to the BO project in the project you want to use them.  Simply go to your project's reference tab and add the BO project, so it can be seen by the new project.  I don't think you have to add a new Tab or do nothing else.

By Trent L. Taylor - 5/21/2008

Actually, if you have manually created a toolbox tab and added the BOs manually to the tab, it will automatically add a reference when dropped on the form.  I am not sure exactly where you are having trouble.  So I just created a quick video that should hopefully get you going down the right path.
By Ger Cannoll - 5/21/2008

You need to configure your AppMain to either setup the data sources for your application manually, or if you plan to use the Connection Wizard, you will need to setup the required data source items.  By default, the template has an SQLDataSourceItem in this list...so you will need to change this.  You can look through the docs on this as well, but you will want to modify your AppMain, open the SetDataSources method, and then change the AddRequiredDataSource call to meet your needs...or you could just manually set the DataSources, but in either case, you need to setup the data sources for your application.

I think I need a bit of guidance here as to best practise. We will be decveloping an App on my machine,say database is in c:\MyApp) and deploying it to clients server (say F:\Apps\KillerApp) in ClientA and G:\Applications\BestApp in Client B. So will need to set up a table/file to hold connection strings. I am unclear where to put this 'stuff' in the Strataframe app. I know when I am setting up the Business Object I specify a connection string , but I understand this is just for development purposes.

In  summary, some guidance on   a)What to do and    b)where in the Stratframe App   I need to set up these strings   would be appreciated

By Trent L. Taylor - 5/22/2008

Gerard,

I think that you are missing the point of how connection strings work in SF.  You can take several avenues here.   First, you can allow SF to manage the connection strings for you (this pertains to design time OR run-time). 

You can use the ConnectionStringWizard or manually setup the connection strings by manually supplying the connection information to the DataSources collection.

Let's first assume that you are going to use the ConnectionStringWizard, then you will define the RequiredDataSources in teh SetDataSources method of the AppMain.vb or program.cs file.  Then when the SetConnections() method is called, it looks on disk to an encrypted file to see if an "active" connection string exists for the ApplicationKey that is also defined in your SetDataSources method.

The connection is not defined on the BO.  The BO uses a DataSourceKey to determine which connection string it will use.  It pulls this connection information from the DataSources collection (MIcroFour.StrataFrame.Data.DataBasics.DataSources).  By default, this would be an empty string.  But you can have as many connections per app as you need and can route the BOs to whichever connection that you need.

Whether you are using the ConnectionStringWizard or manually defined the connection strings, they BOTH end up in the DataSources collection.

I recommend looking at the help as there is a lot of information here.  You can get to it by opening the help and going to Application Framework -> Application -> WinForms -> Connection Strings