vcg03.htm

来自「Visual C++与数据库的连接经典实例」· HTM 代码 · 共 3,468 行 · 第 1/5 页

HTM
3,468
字号

<BR>

<P>This function will return one of the following values:

<BR>



<BR><CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_SUCCESS

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function was successful.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_SUCCESS_WITH_INFO

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function was successful, and more information is available.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_NEED_DATA

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. More information in the input connect string was required than was supplied. Call SQLError() to get more information about the specific failure.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_ERROR

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. Call SQLError() to get more information about the specific failure.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SLQ_INVALID_HANDLE

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. The handle that was passed wasn't a valid handle. Possibly, the function that created the handle had failed and didn't return a valid handle.</FONT>

</TABLE></CENTER><P>If this function fails, your SQL function should end or the error should be corrected; the function should then be re-executed.

<BR>

<P><B>Usage:</B>

<BR>

<P>Call the SQLBrowseConnect() function to enumerate the attributes of a specific datasource. Always check the return code from this function for errors, making additional calls as necessary to gather the desired information to establish the connection.

<BR>

<P><B>Notes:</B>

<BR>

<P>When a return code of either SQL_SUCCESS<B> </B>or SQL_SUCCESS_WITH_INFO<B> </B>is returned, your application will know that the enumeration process has completed and the application is connected to the datasource.

<BR>

<BR>

<A NAME="E69E52"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B><I>SQLCancel()</I></B></FONT></CENTER></H4>

<BR>

<P><B>Prototype:</B>

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">RETCODE SQLCancel (HSTMT <I>hstmt</I>)</FONT></PRE>

<P><B>Parameter:</B>

<BR>



<BR><CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

HSTMT <I>hstmt</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A statement handle returned by the call to SQLAllocStmt().</FONT>

</TABLE></CENTER><P><B>Return Value:</B>

<BR>

<P>This function will return one of the following values:

<BR>



<BR><CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_SUCCESS

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function was successful.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_SUCCESS_WITH_INFO

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function was successful, and more information is available.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_ERROR

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. Call SQLError() to get more information about the specific failure.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SLQ_INVALID_HANDLE

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. The handle that was passed wasn't a valid handle. Possibly, the function that created the handle had failed and didn't return a valid handle.</FONT>

</TABLE></CENTER><P>If this function fails, your SQL function should end or the error should be corrected; the function should then be re-executed.

<BR>

<P><B>Usage:</B>

<BR>

<P>Call the SQLCancel() function to cancel an asynchronous operation pending on the parameter statement indicated by <I>hstmt</I>. Always check the return code from this function for errors.

<BR>

<P><B>Notes:</B>

<BR>

<P>You can cancel functions running on <I>hstmt</I> that are running on other threads. You also can cancel functions on <I>hstmt</I> that require more data.

<BR>

<BR>

<A NAME="E69E53"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B><I>SQLColAttributes()</I></B></FONT></CENTER></H4>

<BR>

<P><B>Prototype:</B>

<BR>

<PRE>

<FONT COLOR="#000080">RETCODE SQLColAttributes (HSTMT <I>hstmt</I>, UWORD <I>icol</I>, UWORD <I>fDescType</I>,

PTR <I>rgbDesc</I>, SWORD <I>cbDescMax</I>, SWORD FAR * <I>pcbDesc</I>, SWORD FAR * <I>pfDesc</I>)</FONT></PRE>

<P><B>Parameters:</B>

<BR>



<BR><CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

HSTMT <I>hstmt</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A statement handle returned by the call to SQLAllocStmt().

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

UWORD <I>icol</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The index to the column in the table that the variable is being bound to.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

UWORD <I>fDescType</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A valid descriptor.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

PTR <I>rgbDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A pointer to the location in the application where the column's data is to be stored. The data type of <I>rgbValue</I> should be defined by <I>fCDescType</I>.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SWORD <I>cbDescMax</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The number of bytes in the storage location pointed to by <I>rgbDesc</I>. Usually, the C sizeof() operator can be passed for this parameter.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SWORD FAR * <I>pcbDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A pointer to an SDWORD variable that will receive the count of how many bytes in <I>rgbDesc</I> were used.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SWORD FAR * <I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A pointer to an integer variable that will receive the results of a query which returns a numeric result.</FONT>

</TABLE></CENTER><P><B>Return Value:</B>

<BR>

<P>This function will return one of the following values:

<BR>



<BR><CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_SUCCESS

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function was successful.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_SUCCESS_WITH_INFO

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function was successful, and more information is available.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_ERROR

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. Call SQLError() to get more information about the specific failure.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SLQ_INVALID_HANDLE

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The function failed. The handle that was passed wasn't a valid handle. Possibly, the function that created the handle had failed and didn't return a valid handle.</FONT>

</TABLE></CENTER><P>If this function fails, your SQL function should end or the error should be corrected; the function should then be re-executed.

<BR>

<P><B>Usage:</B>

<BR>

<P>Call the SQLColAttributes() function to gather information about a column in a table. Always check the return code from this function for errors.

<BR>

<P><B>Notes:</B>

<BR>

<P>Table 3.1 shows the information that will be returned for columns.

<BR>

<BR>

<P ALIGN=CENTER>

<CENTER>

<FONT COLOR="#000080"><B>Table 3.1. Column attributes returned by SQLColAttributes().</B></FONT></CENTER>

<BR>



<BR><CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>Identifier</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>Minimum ODBC </I><I>Version</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>Where Returned</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>Description</I>

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_AUTO_INCREMENT

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns TRUE if the column is an auto-increment column and FALSE if it isn't. Only numeric columns can be auto increment. Values may be inserted into an auto-increment column, but the auto-increment column can't be updated.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_CASE_SENSITIVE

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns TRUE if the column will be considered case-sensitive for sorts and comparisons. Columns that aren't character-based will return FALSE.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_COUNT

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Number of columns that are in the result set. The <I>icol</I> argument will be ignored.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_DISPLAY_SIZE

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the maximum number of characters positions that will be necessary to display data from the column.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_LABEL

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

2.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>rgbDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The column's label or title. As an example, an Access database may have a column called ZipCodes that could be labeled (or titled) &quot;5-Digit Zip Code.&quot; The column name is returned for columns that don't have specified labels or titles. For unnamed columns (such as those found in a text file datasource), an empty string is returned.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_LENGTH

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

The number of bytes of data that will be transferred on an SQLGetData() or SQLFetch() operation when the SQL_C_DEFAULT parameter is specified.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_MONEY

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>pfDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns TRUE if the column is a money data type.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_NAME

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

1.0

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>rgbDesc</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the column name. If the column is unnamed, an empty string is returned. See SQL_COLUMN_LABEL earlier in this table.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SQL_COLUMN_NULLABLE

</FONT>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?