Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC Connection Dialog box (VBA) - deactivate

Status
Not open for further replies.

linedata

Technical User
Nov 14, 2003
1
LU
I would like to prevent the ODBC Connection Dialog box from appearing when I run an Excel VBA macro that queries an ODBC database.

I am using the following code in VBA to open the connection..the query works fine and produces the output but the query box still appears whatever I try (SQL_Driver_NoPrompt etc)...but maybe I have been using it incorrectly. Any help would be much appreciated.

Sub UsingSQLOpen()

Dim Chan As Variant
Dim queryString As String

queryString = "SELECT * from Customers where CustID = 100"

Chan = sqlopen("DSN=TestDSN;UID=TestUser;PWD=Test;SERVER=TestServer;")

SQLExecQuery Chan, queryString
SQLRetrieveToFile Chan, "c:\OUTPUT.TXT", True

SQLClose (Chan)
End Sub
 
I think you need to add one more parameter to you connection string. I think it should use trusted connection.
I hope this wil help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top