XL98: Overview of ODBC Add-in Functions and Arguments (192360)



The information in this article applies to:

  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q192360

SUMMARY

In Microsoft Excel 98 Macintosh Edition, the XLODBC.XLA ODBC add-in provides Open Database Connectivity (ODBC) functions that allow you to connect to external data sources directly. All of the functions are macro commands with the exception of SQL.REQUEST, which is a worksheet function.

NOTE: The functions SQLBind, SQLClose, SQLError, SQLExec, SQLGetSchema, SQLOpen, SQLRetrieve, and SQLRetrieveToFile are displayed in the Function Wizard when the active sheet is a worksheet. However, these functions can be used only in a module sheet.

MORE INFORMATION

The following is a list of the functions provided by XLODBC.XLA and a description of the arguments for those functions. The arguments for each function are shown here as they are displayed in the Function Wizard.

Note that there are some discrepancies in the argument naming conventions used between the Function Wizard and the Help files.

SQLBind(ConnectionNum,Column,Reference)

SQLClose(ConnectionNum)

SQLError()

SQLExecQuery(ConnectionNum,QueryText)

SQLGetSchema(ConnectionNum,TypeNum,QualifierText)

SQLOpen(ConnectionStr,OutputRef,DriverPrompt)

SQLRequest(ConnectionStr,QueryText,OutputRef,DriverPrompt,ColNamesLogi cal)

SQLRetrieve(ConnectionNum,DestinationRef,MaxColumns,MaxRows, ColNamesLogical,RowNumsLogical,NamedRngLogical,FetchFirstLogical)

SQLRetrieveToFile(ConnectionNum,Destination,ColNamesLogical, ColumnDelimiter)

The following is a description of the arguments used in the above functions:
   Argument             Description
   ---------------------------------------------------------------------

   ColNamesLogical      True if you want column names returned as the
                        first row of the results.

   Column               The number of the result column to be bound.
                        Result columns are numbered from left to right
                        starting with 1. Column 0 provides row numbers.
                        If you omit column, all bindings for the
                        connection are removed.

   ColumnDelimiter      The string to use to separate the elements in
                        each row of the created text file. If omitted,
                        a tab is used.

   ConnectionNum        The unique ID returned by SQLOpen for the
                        connection made to the data source.

   ConnectionStr        Supplies information, such as the data source
                        name, user ID, and password, required by the
                        driver being used to connect to a data source.
                        Must follow the driver's format (see the
                        "References" section of this article for
                        information about where the driver's help file is
                        located). Strings longer than 255 characters must
                        be broken into an array of strings.

   Destination          A string that specifies the name and path of
                        the file where you want to place the results.
                        An existing file will be overwritten.

   DestinationRef       A reference specifying the top-left cell where
                        results should be placed. Any previous values
                        in the destination cells are overwritten
                        without confirmation. If omitted, results are
                        placed according to previous calls to SQLBind.

   DriverPrompt         A number specifying if and how the driver should
                        prompt for additional needed information for a
                        connection. Refer to the online help for values.

   FetchFirstLogical    Important only if MaxRows is specified for
                        SQLRetrieve, and there are more rows of results
                        than MaxRows available. Use True to return
                        the first set of rows from the beginning of a
                        query's results. Then call SQLRetrieve repeatedly
                        using False to return the next set of rows until
                        all result rows are returned. Refer to the online
                        help for details.

   MaxColumns           The maximum number of columns to be returned to
                        the worksheet starting at DestinationRef.
                        If omitted, all columns are returned.

   MaxRows              The maximum number of rows to be returned to
                        the worksheet starting at DestinationRef.
                        If omitted, all rows are returned.

   NamedRngLogical      True if you want each column of the results to
                        be declared as a named range on the worksheet.

   OutputRef            A cell reference where you want the completed
                        connection string placed.

   QualifierText        A string that qualifies the information returned
                        by TypeNum--only for a TypeNum of 3, 4, or 5.

   QueryText            The SQL query to be executed on the data source.
                        Strings longer than 255 characters must be broken
                        into an array of strings. While common queries use
                        a standard syntax, there may be differences in
                        driver limitations and extensions (see the
                        "References" section of this article for
                        information about where the driver's help file is
                        located).

   Reference            The location of a single cell on a worksheet where
                        you want the results bound as a Range object.
                        If Reference is omitted, binding is removed for
                        the column.

   RowNumsLogical       Used only when destination is included in the
                        function call. If rowNumbers is True, the
                        first column in the result set contains row
                        numbers. If destination is False or omitted,
                        the row numbers are not returned.

   TypeNum              Specifies the type of information you want
                        returned. Refer to the online help for values.
				

Modification Type:MajorLast Reviewed:9/11/2002
Keywords:kbdtacode kbinfo kbProgramming KB192360