cfront

Hi All, is it possible to get in e.g. c++ via cfront the fields of the primary key of a table? Regards, Frank

As far i am concerned integration with C++ is possible but never tried.

Hi Frank, you can use the function “DBL_GetCurrentKey()”, but you only get the primary key, if “DBL_SetCurrentKey()” has not been called. Best Regards, Richard

It can be done by using DBL_NextKey()

Dear Frank I had writtent this function in VB and i firmly beleive you can have an equivatent of the same in C++ or aby other COM Compliant language First you should call opendatabase to initialize the CF variable and then u can use the GetPKFields function to return the field names in the primary key of the table -Hope this is what u have been looking for '******************Code begins below this line Global CF As CFRONT Public Sub OpenDatabase(NavisionServer As Boolean, _ ServerName As String, _ DatabaseName As String, _ NTAuthentication As Boolean, _ UserID As String, _ Password As String) If NavisionServer Then If ServerName <> “” Then Call CF.ConnectServer(ServerName, gstrNettype) Else CF.HideError = True Call CF.OpenDatabase(DatabaseName, 10000, False) CF.HideError = False End If Else CF.HideError = False Call CF.ConnectServerAndOpenDatabase(“NDBCS”, Trim$(ServerName), _ gstrNettype, Trim$(DatabaseName), 10000, False, NTAuthentication, UserID, Password) End If CF.HideError = False End Sub Public Function GetPKFields(TableName As String) As String() 'this function would take a tablename and return the primary key 'fields of the table in a string array Dim varKeys() As Long, arrKeys() As String Dim hTable As Long, Ctr As Integer hTable = OpenTableByName(TableName) varKeys = CF.GetCurrentKey(hTable) ReDim arrKeys(UBound(varKeys)) For Ctr = LBound(varKeys) To UBound(varKeys) arrKeys(Ctr) = CF.FieldName(hTable, varKeys(Ctr)) Next GetPKFields = arrKeys CF.CloseTable hTable End Function Public Function OpenTableByName(TableName As String) As Long Dim TableNo As Long Call CF.LastError TableNo = CF.TableNo(TableName) CF.HideError = False If CF.LastError <> 0 Then Call CF.ReleaseAllObjects Call CF.OpenTable(OpenTableByName, TableNo) If CF.LastError <> 0 Then Call CF.ReleaseAllObjects End Function

Thanks to all answers!!! Regards, Frank