﻿<?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?)  » Calling a Generic BO</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 13:46:34 GMT</lastBuildDate><ttl>20</ttl><item><title>Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29183.aspx</link><description>&lt;div&gt;&lt;font class="Apple-style-span" color="#000000"&gt;I have a generic BO with the following Sub:&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;Public Sub FillAllData(ByVal objbo As Object)&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Using cmd As New SqlCommand&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.CommandType = CommandType.Text&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.CommandText = String.Format("Select * from {0}", Me.TableNameAndSchema)&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;objbo.FillDataTable(cmd)&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Using&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End Sub&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&lt;br/&gt;&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#000000"&gt;Then I add a BO to my project called CowboysBO which I make sure Inherits from my generic BO. Then I call the sub using the following:&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;Me.CowboysBO1.FillAllData(Me.CowboysBO1)&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#0000FF"&gt;&lt;br/&gt;&lt;/font&gt;&lt;div&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#000000"&gt;Is my logic OK or should I be doing something else? I will use the sub to fill several different BO's and that is why I thought I needed the objbo. The above code seems to work but I don't want to get Bitten.&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#000000"&gt;TIA.......&lt;/font&gt;&lt;div&gt;&lt;font class="Apple-style-span" color="#000000"&gt;&lt;br/&gt;&lt;/font&gt;</description><pubDate>Wed, 08 Dec 2010 09:40:21 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29190.aspx</link><description>You are welcome Terry.&lt;br/&gt;&lt;br/&gt;I am glad you found&amp;nbsp;the problem.&amp;nbsp; And keep in mind that SF BOs are greatly flexible, extensible and powerful, little by little I found the logic used behind them very nice and worthy specially when working with several projects at the same time.</description><pubDate>Wed, 08 Dec 2010 09:40:21 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29189.aspx</link><description>I found the error that was causing the wrong data to load. Thank you again for your help.</description><pubDate>Wed, 08 Dec 2010 09:28:24 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29188.aspx</link><description>I had my code just like yours but I was not getting the correct data. Therefore, I wanted to make sure I could do it the way you indicated and that I originally had, &amp;nbsp;but I must have something not quite right in my other code which is giving me the wrong data. &amp;nbsp;I did put a break on the code but I think I was looking for the BO that was being used and did not find it and did not pay any attention to the table being used.&lt;div&gt;Thank you again for your excellent help.</description><pubDate>Wed, 08 Dec 2010 06:12:50 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29186.aspx</link><description>Terry,&lt;br/&gt;&lt;br/&gt;Your code is using the objbo.FillDataTable(cmd) instead of Me.FillDataTable(cmd).&lt;br/&gt;&lt;br/&gt;Here is how it should be.&amp;nbsp; If you put a break in &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.FillDataTable(cmd) then see the value of cmd.Commandtext, notice that the correct table for the instance of the BO is used, remember "Generic", each BO is created for a specific table, hence the String.Format() code, so when you drop a BO and run the FillAllData() it will work just fine.&amp;nbsp; It is a good idea to take a look at the SF source code to learn how they use this generic logic for the FillBy... methods in the BO class.&lt;br/&gt;&lt;span&gt;[quote]&lt;br/&gt;&lt;/span&gt;&lt;pre style="font-family: consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;Public&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;Overridable&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&amp;nbsp;FillAllData()&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;Using&lt;/span&gt;&amp;nbsp;cmd&amp;nbsp;&lt;span style="color: blue;"&gt;As&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;New&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt;()&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.CommandType&amp;nbsp;=&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;CommandType&lt;/span&gt;.Text&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.CommandText&amp;nbsp;=&amp;nbsp;&lt;span style="color: blue;"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163, 21, 21);"&gt;"Select&amp;nbsp;*&amp;nbsp;From&amp;nbsp;{0}"&lt;/span&gt;,&amp;nbsp;&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.TableNameAndSchema)&lt;br/&gt; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.FillDataTable(cmd)&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;End&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;Using&lt;/span&gt;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;End&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br/&gt;&lt;/pre&gt;&lt;span&gt;[/quote]&lt;/span&gt;</description><pubDate>Tue, 07 Dec 2010 22:01:37 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29185.aspx</link><description>OK but I think I am having trouble with it filling the correct BO since I am using the same Sub to fill multiple BO's but I will try again and see what happens. Thanks.</description><pubDate>Tue, 07 Dec 2010 20:33:19 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Calling a Generic BO</title><link>http://forum.strataframe.net/FindPost29184.aspx</link><description>Hi Terry,&lt;br/&gt;&lt;br/&gt;You don't need to pass any parameter nor the current BO.&lt;br/&gt;&lt;br/&gt;Your current class, by inheriting the base BO it will know from which BO the method is executing, so when you reference Me in the base BO code it will be using whatever BO you have inherited from the base.&lt;br/&gt;&lt;br/&gt;It may sound too easy, but it works and it is the way it is &lt;span&gt;:)&lt;/span&gt;</description><pubDate>Tue, 07 Dec 2010 18:51:31 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>