Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ODBC API - SQLPrimaryKeys() not working
Message
De
18/12/1999 13:11:58
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
ODBC API - SQLPrimaryKeys() not working
Divers
Thread ID:
00305684
Message ID:
00305684
Vues:
51
Hi!

I need some help on these two ODBC API Functions
SQLPrimaryKeys and SQLForeignKeys

I am trying to get the PrimaryKey and ForeignKey info. for any specified table from the backend.
I don't want to call a Stored Procedure (sp_pkeys, sp_fkeys) as they could/would be different across backends.

The following program always returns 65534 Don't know why! What am I doing wrong here. (when I call SQLPrimaryKeys() with its parameters)
I would appreciate a working example of both functions (SQLPrimaryKeys and SQLForeignKeys()) if possible.

Also help on converting VB types to VFP
e.g.
"ByVal hstmt&" -> integer
szTblQualifier As Any -> string @
ByVal cbTblQualifier% -> ingeter
etc.

Thanks.

Sarosh

*--
Func GetPKeys(as_TblQualifier, as_TblOwner, as_TblName)
local ls_Return

m.olddec = set("decimal")
set deci to 0
hstmt = val(SYS(3053)) && SYS(3053) - ODBC Environment Handle
set deci to (m.olddec)
*--
m.max = 128
szTblQualifier = as_TblQualifier &&padr("northwnd",m.max) &&+ chr(0)
cbTblQualifier = len(szTblQualifier)
*--
szTblOwner = as_TblOwner &&padr("dbo",m.max) &&+ chr(0)
cbTblOwner = len(szTblOwner)
*--
szTblName = as_TblName &&padr("Products",m.max) &&+ chr(0)
cbTblName = len(szTblName)
*--
Declare integer SQLPrimaryKeys in "odbc32.dll" integer hstmt, string @ szTblQualifier, integer cbTblQualifier, string @ szTblOwner, integer cbTblOwner, string @ szTblName, integer cbTblName

ls_Return = SQLPrimaryKeys(hstmt, @szTblQualifier, cbTblQualifier, @szTblOwner, cbTblOwner, @szTblName, cbTblName)
*--returns 65534

Return ls_Return

*--
*-- VB ODBC API's Definitions -- 32 bit versions

*-- Declare Function SQLForeignKeys Lib "odbc32.dll" (ByVal hstmt&, ByVal PTQual&, ByVal PTQual%, ByVal PTOwnr&, ByVal PTOwnr%, ByVal PTName&, ByVal PTName%, ByVal FTQual&, ByVal FTQf%, ByVal FTOwnr&, ByVal FTOwnr%, ByVal FTName&, ByVal FTName%) As Integer

*-- Declare Function SQLPrimaryKeys Lib "odbc32.dll" (ByVal hstmt&, szTblQualifier As Any, ByVal cbTblQualifier%, szTblOwner As Any, ByVal cbTblOwner%, szTblName As Any, ByVal cbTblName%) As Integer
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform