﻿<?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?)  » I am trying to use GetByPrimaryKey() in my Function but having problems</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 23:46:01 GMT</lastBuildDate><ttl>20</ttl><item><title>I am trying to use GetByPrimaryKey() in my Function but having problems</title><link>http://forum.strataframe.net/FindPost9763.aspx</link><description>Hi all. I have a login form that has a combo box that lists users. When the user selects himself his ID ( a primary key value in the table) is loaded in lnValue and  sent to my function GetEmployeeByID.  The idea is to get the execute the query and return the one record based on the ID value using the GetByPrimaryKey Method. For some reason no matter what value is sent thru ID the return is always from the first record with a ID value of 1.  I have used the debugger to check values of ID to the function and it is 2 that is being sent but when I get back to my form the password in the dataset is from record 1. Clear as mud? In other words I'm asking for record 2 and am getting record 1. So,is my code correct or have I not understood your example of how to use the GetByPrimaryKey?  BWT, ID is the primary key for this table.&lt;br&gt;
&lt;br&gt;
Regards,&lt;br&gt;
&lt;br&gt;
Robert&lt;br&gt;
&lt;br&gt;
---CODE FROM MY FORM------&lt;br&gt;
        Dim lnValue as Integer&lt;br&gt;
        '-- Get the ID from the selected name in the combo box&lt;br&gt;
        lnValue = CType(txtFullName.SelectedValue, Integer)&lt;br&gt;
&lt;br&gt;
        '-- Send the ID to the Function that will get the Password from the DB of the selected user&lt;br&gt;
        Me.EmployeeBO1.GetEmpoyeeByID(lnValue)&lt;br&gt;
&lt;br&gt;
---CODE FROM MY EMPOYEEBO1-------&lt;br&gt;
   Public Function GetEmpoyeeByID(ByVal ID As Integer)&lt;br&gt;
&lt;br&gt;
        Return Me.GetByPrimaryKey(ID)&lt;br&gt;
&lt;br&gt;
   End Function&lt;br&gt;</description><pubDate>Mon, 25 Jun 2007 14:51:03 GMT</pubDate><dc:creator>Robert Carl Johnson</dc:creator></item><item><title>RE: I am trying to use GetByPrimaryKey() in my Function but having problems</title><link>http://forum.strataframe.net/FindPost9788.aspx</link><description>No problem at all :)&amp;nbsp; This is exactly why this forum exists :)</description><pubDate>Mon, 25 Jun 2007 14:51:03 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: I am trying to use GetByPrimaryKey() in my Function but having problems</title><link>http://forum.strataframe.net/FindPost9785.aspx</link><description>Rock n' Roll.  I'm getting there.. lol.&lt;br&gt;
&lt;br&gt;
Thanks guys. I appreciate the patience with a newbie to .Net I spent a lot of years in another language so this stuff is quite new to me but I'm getting my head around it.&lt;br&gt;
&lt;br&gt;
Robert</description><pubDate>Mon, 25 Jun 2007 13:49:40 GMT</pubDate><dc:creator>Robert Carl Johnson</dc:creator></item><item><title>RE: I am trying to use GetByPrimaryKey() in my Function but having problems</title><link>http://forum.strataframe.net/FindPost9778.aspx</link><description>Correct :)</description><pubDate>Mon, 25 Jun 2007 13:02:17 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: I am trying to use GetByPrimaryKey() in my Function but having problems</title><link>http://forum.strataframe.net/FindPost9772.aspx</link><description>Ben, thanks for the reply. So to recap, I am going to use your suggested method because I already have a dataset and I want to view another record from it, correct? I would only use GetByPrimaryKey(Pk) when I need to get another dataset.&lt;br&gt;
&lt;br&gt;
Regards,&lt;br&gt;
&lt;br&gt;
Robert</description><pubDate>Mon, 25 Jun 2007 09:28:59 GMT</pubDate><dc:creator>Robert Carl Johnson</dc:creator></item><item><title>RE: I am trying to use GetByPrimaryKey() in my Function but having problems</title><link>http://forum.strataframe.net/FindPost9768.aspx</link><description>It looks like your problem is that you're using the GetByPrimaryKey() instead of FillByPrimaryKey() within the GetByEmployeeID() method.&amp;nbsp; If the business object is already filled, and you call GetByPrimaryKey(), it won't change anything within the business object... it will just return a new DataTable containing the information you requested rather than filling the business object with the data that you want.&amp;nbsp; So, when you check Me.EmployeeBO1, it's data isn't going to change when you call GetByEmployeeID().&amp;nbsp; What you want to do is change the GetByEmployeeID() to a Sub and change the "Return Me.GetByPrimaryKey(ID)" to "Me.FillByPrimaryKey(ID)" (there's nothing to return since it takes the requested data and puts it inside the business object.</description><pubDate>Mon, 25 Jun 2007 09:00:06 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>