Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
issue with ODBC connection to DB2 Avi Excel Programming 2 August 2nd 07 10:06 PM
ODBC connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:48 PM
ODBC Connection Kezzemil Excel Programming 0 October 6th 06 09:15 AM
ODBC Connection Adrian T[_4_] Excel Programming 4 January 25th 05 08:55 PM
ODBC connection by udl Dorothy[_4_] Excel Programming 1 January 8th 04 05:32 PM


All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"