﻿<?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?)  » BO as parameter</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 10:40:38 GMT</lastBuildDate><ttl>20</ttl><item><title>BO as parameter</title><link>http://forum.strataframe.net/FindPost28088.aspx</link><description>Hi all,&lt;br&gt;
&lt;br&gt;
public sub get_code_from_key()&lt;br&gt;
        Dim loBO = New BO_Library.employee&lt;br&gt;
        loBO.FillByPrimaryKey(4)&lt;br&gt;
        Dim lcCode As String = loBO.CurrentRow(1)&lt;br&gt;
End sub&lt;br&gt;
&lt;br&gt;
Above sub module is work. How do i convert into function and parameter BO's name is passing?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
public function get_code_from_key(byval BO as ???,  byval key as integer)&lt;br&gt;
         Dim loBO = New BO_Library.BO&lt;br&gt;
         loBO.FillByPrimaryKey(key)&lt;br&gt;
         Dim lcCode As String = loBO.CurrentRow(1)&lt;br&gt;
Return lcCode &lt;br&gt;
End function&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
** My collection of BO is under assembly BO_Library&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Please help...</description><pubDate>Wed, 25 Aug 2010 20:18:54 GMT</pubDate><dc:creator>Tiong Diu King</dc:creator></item><item><title>RE: BO as parameter</title><link>http://forum.strataframe.net/FindPost28108.aspx</link><description>You are welcome, Tiong.&lt;/P&gt;&lt;P&gt;I am really happy you got it working. :cool:</description><pubDate>Wed, 25 Aug 2010 20:18:54 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: BO as parameter</title><link>http://forum.strataframe.net/FindPost28104.aspx</link><description>Hi Ivan,&lt;br&gt;
&lt;br&gt;
I wanna thanks for your help again and again. Your sample is work great...</description><pubDate>Wed, 25 Aug 2010 19:29:45 GMT</pubDate><dc:creator>Tiong Diu King</dc:creator></item><item><title>RE: BO as parameter</title><link>http://forum.strataframe.net/FindPost28093.aspx</link><description>Download the sample from the following link and have a look at the Base BO concept. This way you won't have to repeat this kind of code.&lt;/P&gt;&lt;P&gt;&lt;A href="http://forum.strataframe.net/FindPost27794.aspx"&gt;http://forum.strataframe.net/FindPost27794.aspx&lt;/A&gt;</description><pubDate>Wed, 25 Aug 2010 11:53:39 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: BO as parameter</title><link>http://forum.strataframe.net/FindPost28092.aspx</link><description>Hi Edhy,&lt;br&gt;
&lt;br&gt;
your method is doing the code at BO. I don't want the code doing at BO because if i have 50 BO then i need do it 50 times. I want only 2 function there are &lt;br&gt;
1) pass BO's name and primary key then function return me code &lt;br&gt;
2) pass BO's name and code then function return me primary key&lt;br&gt;
&lt;br&gt;
Please advice...&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Hi Ivan,&lt;br&gt;
&lt;br&gt;
I did declare the BO as As MicroFour.StrataFrame.Business.BusinessLayer but it doesn't work.&lt;br&gt;
when i create new instance of the BO with the parameter BO but there is the error code&lt;br&gt;
etc:  Dim loBO As BO_Library.BO&lt;br&gt;
&lt;br&gt;
Please advice...</description><pubDate>Wed, 25 Aug 2010 11:07:44 GMT</pubDate><dc:creator>Tiong Diu King</dc:creator></item><item><title>RE: BO as parameter</title><link>http://forum.strataframe.net/FindPost28090.aspx</link><description>Hi Tiong.&lt;/P&gt;&lt;P&gt;Also, regarding having your BO as a function parameter, follow this link to get an idea:&lt;/P&gt;&lt;P&gt;&lt;A href="http://forum.strataframe.net/FindPost28016.aspx"&gt;http://forum.strataframe.net/FindPost28016.aspx&lt;/A&gt;</description><pubDate>Wed, 25 Aug 2010 06:12:24 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: BO as parameter</title><link>http://forum.strataframe.net/FindPost28089.aspx</link><description>Hi Tiong,&lt;br&gt;
&lt;br&gt;
There are many ways to do this depending on what you really want.  If you want to use this function from several places then you don't have to fill the BO you can run an scalar method to get that particular field value for lcCode.  Take a look at the help file, there are sample code almost all over, also the forum have a ton of experiences with many code samples too.&lt;br&gt;
&lt;br&gt;
Keep in mind that your BO class is also the place to add functions and methods that apply to the BO or anything you want and that will also make it easier for you to access those functions and methods.  So let's say you need to get the cCode field from the Employee BO, you would create a method in the BO class to return that field, something like this:&lt;br&gt;
[quote]&lt;br&gt;
   Public Function get_code_from_key(ByVal PKValue As Integer) As String&lt;br&gt;
        Using cmd As New SqlCommand()&lt;br&gt;
            '-- Build the command&lt;br&gt;
            cmd.CommandType = CommandType.Text&lt;br&gt;
            cmd.CommandText = "SELECT Employee.Code FROM Employee WHERE EmployeePK = @EmployeePKValue"&lt;br&gt;
&lt;br&gt;
            '-- Create and set the parameters&lt;br&gt;
            cmd.Parameters.AddWithValue("@EmployeePKValue", PKValue).SqlDbType = SqlDbType.Int&lt;br&gt;
&lt;br&gt;
            '-- Execute the query and return the value&lt;br&gt;
            Return CType(Me.ExecuteScalar(cmd), String)&lt;br&gt;
        End Using&lt;br&gt;
    End Function&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
By adding above function to the BO, you can now call it from any instance of the BO being use like this:&lt;br&gt;
[quote]&lt;br&gt;
Dim loBo as New BO_Library.EmployeeBO&lt;br&gt;
Dim lcCode as String = loBO.get_code_from_key(Your PK Value)&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
Still that is not foolproof, there are several things to be enhanced, like checking for DBNull, etc., but I leave that as a homework for you :D  Hint: there are plenty of samples on this in the forums.</description><pubDate>Wed, 25 Aug 2010 06:09:36 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>