XL: SQL.REQUEST and SQLREQUEST Function Syntax Differences

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

Microsoft provides programming examples 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. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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)
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.00c 97

Keywords : kbprg kbdta KbVBA
Version : WINDOWS:5.0,5.0c,7.0,97
Platform : WINDOWS
Issue type :


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.