Microsoft KB Archive/85574

{| = DB.LOGON Required Before DB.SQL.QUERY To A SQL Server =
 * width="100%"|

Last reviewed: November 4, 1994

Article ID: Q85574 Summary: When using the DB.Functions provided by QE.XLA to query an SQL Server table, it is necessary to use DB.LOGON(&quot;SQLServer&quot;) prior to sending the DB.SQL.QUERY command. Otherwise, the DB.SQL.QUERY statement will fail and the result of the DB.SQL.QUERY will be a #REF!.

More Information:

The DB.SQL.QUERY command in the QE.XLA tests what sources are available before allowing the query. If the source in the query is not available, the macro fails and returns a #REF!.

Steps to Reproduce Problem
  In Excel, open a new macro sheet. Enter the following: =DB.SQL.QUERY(2,&quot;use pubs; Select * from SQLServer | sales&quot;)  Change to a worksheet and execute the macro. Nothing will be returned. Add &quot;=DB.LOGON(&quot;SQLServer&quot;)&quot; (without quotation marks) before the DB.SQL.QUERY command. Again, execute the macro. This time, after correctly logging on to the SQL Server, information will be returned.

Reference(s): &quot;Q+E for Microsoft Excel User's Guide,&quot; pages 69-72
 * }