>Hi!
>
>Tried it out but it still returns 65534
>
You need to issue a SQLGetDiagRec to retrieve the extended error code.
>ls_PKey = GetPKeys("northwnd","dbo","Products")
>*-- ls_PKey is always 65534
>
>Sarosh
>
>Func GetPKeys(as_TableQualifier, as_TableOwner, as_TableName)
>local ls_Return, oHeap, nCatNamePtr, nSchNamePtr, nTabNamePtr, m.olddec
>
>m.olddec = set("decimal")
>set deci to 0
>hstmt = val(SYS(3053)) && SYS(3053) - ODBC Environment Handle
>set deci to (m.olddec)
>
>DECLARE INTEGER SQLPrimaryKeys IN ODBC32 ;
>INTEGER hStmt, ;
>INTEGER nCatalogNamePtr, ;
>SHORT nCatalogNameLength, ;
>INTEGER nSchemaNamePtr, ;
>SHORT nSchemaNameLength, ;
>INTEGER nTableNamePtr, ;
>SHORT nTableNameLength
>
>SET PROC TO CLSHEAP ADDITIVE
>oHeap = CREATEOBJ('Heap')
>nCatNamePtr = oHeap.AllocString(as_TableQualifier)
>nSchNamePtr = oHeap.AllocString(as_TableOwner)
>nTabNamePtr = oHeap.AllocString(as_TableName)
>
>ls_Return = SQLPrimaryKeys(hstmt, ;
>@ nCatNamePtr, ;
>LEN(as_TableQualifier) + 1, ;
>@ nSchNamePtr, ;
>LEN(as_TableOwner)+ 1, ;
>@ nTabNamePtr, ;
>LEN(as_TableName) + 1 )
>
>oHeap = null
>RELEASE PROC CLSHEAP
>
>Return ls_Return