XL: SQL.REQUEST and SQLREQUEST Function Syntax Differences

Last reviewed: September 2, 1997
Article ID: Q117364
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel 97 for Windows

SUMMARY

In the versions of Microsoft Excel listed at the beginning of this article, the arguments in the SQL.REQUEST function and the SQLREQUEST are the same in the two functions, but the order of the arguments is different.

MORE INFORMATION

Two functions in the XLODBC.XLA add-in, SQLRequest (Visual Basic function) and SQL.REQUEST (worksheet function and Microsoft Excel 4.0 macro function), allow you to connect to an external data source and run a query. Most functions that are available as macro commands and worksheet functions have the same syntax. This is not the case with SQLRequest and SQL.REQUEST.

You can use the FunctionWizard to view the differences in the order of the arguments in the two functions. The following sections contain correct syntax for and an example of each function.

SQLRequest

SQLRequest is a Visual Basic function. The correct syntax is as follows:

   SQLRequest(connectionStr, query, output, prompt, columnNames)

You can use this function in a formula on a worksheet, or in a Visual Basic procedure. Note that the SQLRequest function syntax shown in the FunctionWizard is as follows (different argument names):

   SQLRequest(ConnectionStr,QueryText,OutputRef,DriverPrompt,
      ColNamesLogical)

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

Module Code Example:

   SQLRequest("DSN=NWind;DBQ=c:\msquery;FIL=dBASE4", _
      "Select Custmr_id, Due_date from orders where order_amt > 100", _
      Worksheets("Sheet1").Range("C15"), 2, TRUE)

To use this formula on a worksheet, you must type these lines as one logical line; do not use the line continuation character.

Worksheet Example:

   =SQLRequest("DSN=NWind;DBQ=c:\msquery;FIL=dBASE4",
      "Select Custmr_id, Due_date from orders where order_amt > 100",
      C15, 2, TRUE)

SQL.REQUEST

SQL.REQUEST is a worksheet function and an MS Excel 4.0 macro command. The correct syntax is as follows:

   SQL.REQUEST(connection_string,output_ref,driver_prompt,query_text,
      col_names_logical)

Note that this is the SQL.Request function syntax shown in the FunctionWizard as well as the syntax shown in the Help file for the SQLREQUEST function.

NOTE: In Microsoft Excel for Windows 95, versions 7.0 and 97, filenames, passwords, table names, and database names are case sensitive in SQL.REQUEST.

Example:

   =SQL.REQUEST("DSN=NWind;DBQ=c:\msquery;FIL=dBASE4", C15, 2,
      "Select Custmr_ID, Due_Date from Orders WHERE order_Amt>100", TRUE)

NOTE: The connection string and the query text arguments are required for both the SQLRequest function and the SQL.REQUEST function.


Additional query words: 5.00 5.00c 7.00 97

Keywords : kbprg ODBCGen kbcode kbprg
Version : 5.00 5.00c 7.00 97
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.