Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SQL ODBC Connection
Hello,
I am using the below code to connect to an SQL server in Excel 2003 and run a query. The code works fine and runs the query, but the only problem is that I have to manually click ok to select the server & click ok to confirm the user ID and Password, even though its already been enetered. Is there a way to automate this so it runs without any user interacton? Dim varConn As String Dim varSQL As String varConn = "ODBC;DSN= Sql_Server;UID=" & Range("J2") & ";PWD=" & Range("J2") varSQL = Range("H2") With ActiveSheet.QueryTables.Add(Connection:=varConn, Destination:=Range("A1")) .CommandText = varSQL .Name = "Query-39008" .Refresh BackgroundQuery:=False End With Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
issue with ODBC connection to DB2 | Excel Programming | |||
ODBC connection failed. | Excel Discussion (Misc queries) | |||
ODBC Connection | Excel Programming | |||
ODBC Connection | Excel Programming | |||
ODBC connection by udl | Excel Programming |