ODBC API Common Function Interpretation

xiaoxiao2021-04-10  425

The following is a common fourteen functions of the ODBC API, and the external function reference declares:

Function Integer Sqlallocenv (Ref Long Phenv) Library "ODBC32.DLL"

Function Integer Sqlfreeenv (Long Henv) library "odbc32.dll"

Function Integer SqlDataSource (Long Henv, Int FDIRECTION, REF STRING SZDSN, &

Integer Cbdsnmax, Ref Integer PCBDSN, Ref String Szdescription, INTEGER CBDESCRIPTIONMAX, REF INTEGER PCBDESCRIPTION, LIBRARY "ODBC32.DLL"

Function Integer SQLALLOCCONNECT (long Henv, Ref Long HDBC) library "odbc32.dll"

Function Integer SqlConnect (Long Hstmt, Ref string szdsn, Integer DSnlen, Ref String

Szuid, Integer Uidlen, Ref string szpwd, integer pwdlen, library "odbc32.dll"

Function Integer Sqldisconnect (long hdbc) library "odbc32.dll"

Function Integer SqlallocStmt (long hdbc, ref long hstmt) library "odbc32.dll"

Function Integer Sqltables (Long Hstmt, Ref String Sztablequalifier, Integer Tablequalifierlen, Ref String Szowner, Integer Owerlen, Ref String Szname, Integer Namelen,

Ref string sztype, integer typelen) library "odbc32.dll"

Function Integer Sqlcolumns (Long Hstmt, Ref String Sztablequalifier, Integer Tablequalifierlen, Ref String Szowner, Integer Owerlen, Ref String Szname, Integer Namelen,

Ref string sztype, integer typelen) library "odbc32.dll"

Function Integer Sqlbindcol (Long Hstmt, Integer Colnum, Integer Dattype, Ref String Name, Long Maxlen, Ref Long Actlen) Library "ODBC32.DLL"

Function Integer SQLFETCH (Long HSTMT) library "odbc32.dll"

Function Integer SQLERROR (Long LENV, Long HDBC, Long Hstmt, Ref String Sqlstate, Ref Long NativeError, Ref String ErrorMsg, Integer ErrorMsgmax, Ref Integer ErrorMsglen) library "odbc32.dll"

Function Integer SQLFreeStmt (Long HSTMT, Integer Options) library "odbc32.dll" 1, function integer sqlallocenv (ref long phenv) library "odbc32.dll"

Parameters: Ref long phenv Reference The handle of the OBDC environment returned by the transferee.

The value stored in PhenV became the unique identifier called after the OBDC API function.

Return Value: When the Integer is successful, it returns 0, and the failed return value is less than 0.

Function function: Get the ODBC environment handle.

2, Function Integer Sqlallocstmt (Long HDBC, Ref Long HSTMT) library "odbc32.dll"

Parameters: The handle of the long HDBC ODBC environment.

Ref long hstmt saves the SQL statement handle.

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Get the SQL statement handle.

3, Function Integer SqlConnect (long hstmt, ref string szdsn, integer dsnlen, ref string szuid, integer uidlen,

Ref string szpwd, integer pwdlen) library "odbc32.dll"

Parameters: Long HSTMT, call the SQLAlLocStmt () function to obtain the handle.

REF STRING SZDSN, ODBC Data Source Name.

Integer DSNLEN, the length of the ODBC data source name.

Ref string szuid, user account.

Integer uidlen, user account length.

Ref string szpwd, user password.

Ref integer pwdlen, user password length.

Return value: Integer, when successful, the return value is greater than 0, the return value is less than 0.

Function function: Connect the ODBC data source and return to the connection handle.

4, Function Integer Sqldisconnect (long hdbc) library "odbc32.dll"

Parameters: long HDBC Connection Handle.

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Disconnect the ODBC data source.

5, function integer SQLTables (long hstmt, ref string sztablequalifier, integer tablequalifierlen, ref string szowner, integer owerlen, ref string szname, integer namelen, ref string sztype, integer typelen) library "odbc32.dll"

Parameters: Long HSTMT SQL Statement Handle

Ref string sztablequalifier table Qualifier name.

The length of the Qualifier name of the Integer Tablequalifierlen table.

The owner name of the Ref string Szowner table.

The owner of the Integer Owerlen table.

Ref string szname table name.

Integer Namelen table name length.

The type name of the REF STRING SZTYPE table.

The type name length of the INTEger Typelen table.

Return Value: Integer, when successful, return 0, failure return value is less than 0. Function function: Get information on the table.

6, function integer SQLColumns (long hstmt, ref string sztablequalifier, integer tablequalifierlen, ref string szowner, integer owerlen, ref string szname, integer namelen, ref string sztype, integer typelen) library "odbc32.dll"

Parameters: Long HSTMT SQL Statement Handle

Ref string sztablequalifier table Qualifier name.

The length of the Qualifier name of the Integer Tablequalifierlen table.

The owner name of the Ref string Szowner table.

The owner of the Integer Owerlen table.

Ref string szname table name.

Integer Namelen table name length.

The type name of the REF STRING SZTYPE table.

The type name length of the INTEger Typelen table.

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Get column information for the specified table.

7. Function Integer Sqlbindcol (Long Hstmt, Integer Colnum, Integer DataType, Ref String Name, Long Maxlen,

Ref long actlen) Library "odbc32.dll"

Parameters: Long HSTMT SQL Statement Handle

Integer Colnum 1-5 (Is there a qualification, owner name, type, comment.

Integer DataType 1-8, 12, 99.

Ref string Name program string variable.

Long Maxlen varies.

Ref long actlen variable.

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Binding result set.

8, Function Integer Sqlfetch (Long HSTMT) library "odbc32.dll"

Parameters: Long HSTMT SQL Statement Handle

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Binding result set.

9, Function Integer SQLERRRO (Long LENV, Long HDBC, Long Hstmt, Ref String Sqlstate, Ref Long NativeError, Ref String ErrorMsg, Integer ErrorMsgmax, Ref Integer ErrorMsglen) library "odbc32.dll"

Parameters: Long Lenv ODBC Environment Handle

Long HDBC Connection Handle

Long HSTMT SQL statement handle

Ref string SQLState is used to accept strings that contain SQL error identifiers

Ref long nativeError is used to accept the included SQL error identification code

Ref string errormsg is used to accept a string containing SQL error information

Integer ERRORMSGMAX function returns the maximum number of characters

The actual number of characters returned by the REGER ERRORMSGLEN function

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Return to call the ODBC API function error. 10, Function Integer Sqlfreeenv (long Henv) library "odbc32.dll"

Parameters: Long Lenv ODBC Environment Handle

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Release the ODBC environment handle.

11, Function Integer SqlfreeStmt (Long HSTMT, Integer Options) library "odbc32.dll"

Parameters: Long HSTMT SQL Statement Handle.

Integer Options Related options.

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Release the SQL statement handle.

12, function integer SQLDataSources (long henv, int fdirection, ref string szdsn, integer cbdsnmax, ref integer pcbdsn, ref string szdescription, integer cbdescriptionmax, ref integer pcbdescription) library "odbc32.dll"

Parameters: Long Henv ODBC Data Source Environment Handle.

Int fdirection direction sign 1 (next), 2 (first), 3 (last one), 4 (the former one)

Ref string szdsn data source name

Integer CBDSNMAX data source name maximum length

Ref Integer PCBDSN Data Source Name actual length

Ref string szdescription data source description name

Integer CBDescriptionMAX Data Source Description Strings Maximum Length

Ref integer pcbdescription data source describes the actual length of the string

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Release the SQL statement handle.

13. Function Integer Sqlallocconnect (long Henv, Ref Long HDBC) library "odbc32.dll"

Parameters: Long Henv ODBC Data Source Environment Handle.

Ref long hdbc saves the ODBC connection handle.

Return Value: Integer, when successful, return 0, failure return value is less than 0.

Function function: Get the ODBC connection handle.

- :) The above finally describes the listed ODBC API functions, and the like has time to explain how to use the ODBC API function to access the database.

转载请注明原文地址:https://www.9cbs.com/read-133244.html

New Post(0)