StrataFrame Forum

SeekToPrimaryKey

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

By Larry Caylor - 5/11/2006

SeekToPrimaryKey and NavigateToPrimaryKey do not appear to be working properly for compound primary keys. Looking at the source code I believe there is a bug in Private Function GetIndexOfPrimaryKey.

 

Private Function GetIndexOfPrimaryKey(ByVal ParamArray PrimaryKeyValues As Object()) As Integer

            '-- Establish locals

            Dim lnReturn As Integer = -1

            Dim lnCnt As Integer

            Dim loRow As DataRow

            Dim lcSelect As String = String.Empty

 

            '-- Make sure the length of the primary key values and the length of the fields matches

            If Me.PrimaryKeyFields.Length <> PrimaryKeyValues.Length Then

                Throw New ArgumentException("The number of PrimaryKeyValues passed must match the number of PrimaryKeyFields on the business object.")

            End If

 

            '-- Find the row

            Try

                '-- Create the primary key string

                For lnCnt = 0 To Me.PrimaryKeyFields.Length - 1

                    '-- Add the "AND" if necessary

                    If lnCnt > 0 Then

                        lcSelect &= " AND "

                    End If

 

                    '-- Add the select value

                    lcSelect = Me.PrimaryKeyFields(lnCnt) & "='" & PrimaryKeyValues(lnCnt).ToString() & "'"

                Next

 

When there is more than 1 primary key field, the previous value of lcSelect gets over written. Changing the statement under “‘—Add the select value”  to the following should fix the problem.

 

lcSelect = lcSelect & Me.PrimaryKeyFields(lnCnt) & "='" & PrimaryKeyValues(lnCnt).ToString() & "'"

 

-Larry

 

By StrataFrame Team - 5/11/2006

Right you are, Larry BigGrin

I'll get the "=" changed to "&="

Thanks for the heads up.

By StrataFrame Team - 5/11/2006

It's been fixed... and will be in the release with the DevExpress wrapper probably next week.
By Larry Caylor - 5/11/2006

Ben,

That's great. I can work around the issue till then.

Thanks,

-Larry

By StrataFrame Team - 5/11/2006

Yes, you can even change your source code and then recompile it, if you need to.  There's a batch file that will automatically register the recompiled DLLs in the GAC and copy them to the Program Files\Common Files\MicroFour\StrataFrame\ folder.
By Larry Caylor - 5/12/2006

Ben,

Thanks for the tip. I found the afterbuild.bat file in "Program Files\MicroFour\StrataFrame Source Code\"

-Larry

By StrataFrame Team - 5/12/2006

No problem.  We distribute that file so if you want/need to make source code changes, you don't have to worry about registering your new DLLs in the GAC every time.