Microsoft KB Archive/117364

= SQL.REQUEST and SQLREQUEST Function Syntax Differences =

Article ID: 117364

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q117364



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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. 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 XL

Keywords: kbprogramming KB117364

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.