SQL.REQUEST

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

Returns the result after connecting to a data source and executes a SQL query.

connection_stringThe data source name, user id and password required by the driver.
output_refThis is only relevant when you are not calling this function from a worksheet.
driver_promptThe option for whether the driver prompt dialog box is displayed:
1 = dialog is always displayed
2 = dialog is only displayed when there is insufficient information (options are available)
3 = dialog is only displayed when there is insufficient information (options are not available)
4 = dialog is not displayed and an error is returned if unsuccessful
query_textThe SQL statement you want to execute.
col_names_logicalTrue or False to specify if column names are returned as part of the result.

REMARKS
* Removed in 2003.
* This function is only available if you have the Open Database Connectivity add-in installed.
* This add-in was removed in Excel 2003 and replaced with ActiveX Data Objects
* This function did not appear in the 'Insert Function' dialog box.
* Using this old Excel 7.0 add-in is not recommended as the ADO (ActiveX Data Object) library has since become the preferred method for connecting to external data sources.
* The "connection_string" must be in the exact format for that particular driver.
* The "connection_string" for dBase might be - DSN=Nwind;PWD=password.
* The "connection_string" for SQL Server might be - DSN=ServerName; Database=People; UID=name; PWD=password.
* The "connection_string" for Oracle might be - DNS=OracleDataSource; DBQ=Name; UID=name; PWD=password.
* The "connection_string" must always contain the DNS (Data Source Name).
* The "connection_string" can be entered as an array.
* If the "connection_string" is longer than 250 characters you must enter it as an array.
* If the "connection_string" is not valid and a connection cannot be made, then #N/A! is returned.
* If "driver_prompt" is left blank, then 2 is used.
* The "query_text" can be made up of cell references.
* If "query_text" is longer than 255 characters then split the query into a group of vertical cells and pass in the cell range.
* If "query_text" is invalid SQL or cannot be executed, then #N/A! is returned.
* If "col_names_logical" is left blank, then False is used.
* If this function is successful it will either return the result as an array or the number of rows affected.

 A
1=SQL.REQUEST("DSN=Nwind; DBQ=C:\Temp\MsQuery; FIL=dBASE4", A1, 2, "SELECT Customer_ID FROM Orders WHERE OrderNo > 200", True)
2=SQL.REQUEST("DSN=MS Access Database; DBQ=C:\Temp\Nwind.mdb" ,,,"SELECT City FROM Customers WHERE (CustomerID='435')")


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top