Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
JamesBraun
Starting Member
6 Posts |
Posted - 2007-07-17 : 11:11:41
|
Hi,Currently I am trying to connect to SQL Server 2005 via Excel VBA. I would like to create a connection to the server as I have previously done with my 2000 server. However, the diffence this time is that I am using Active Directory so there are no specific log-in's for SQL per se just Windows Users that are part of groups, any of which could use this spreadsheet. So where-as previously I included the username and password for SQL Server in the connection string I would now like to use the credentials currently logged onto the particular machine.My previous code was thisPublic Function getConnection() As ADODB.Connection ' Create a connection object. Dim Conn As ADODB.Connection Set Conn = New ADODB.Connection ' Provide the connection string. Dim strConn As String 'Use the SQL Server OLE DB Provider. strConn = "Network Library=DBMSSOCN;PROVIDER=SQLOLEDB;" 'Connect to the Pubs database on the local server. strConn = strConn & "DATA SOURCE=SQL02,1433;INITIAL CATALOG=dbDataWareHouse;" 'Use a login. strConn = strConn & " Uid=*******;Pwd=******;" 'Now open the connection. Conn.ConnectionString = strConn Conn.Open Set getConnection = Conn End FunctionWould anyone be able to point me in the eight direction ? Your help would be much appreciatedMany ThanksJames |
|
tmitch
Yak Posting Veteran
60 Posts |
Posted - 2007-07-23 : 22:20:53
|
For any connection string question, a great resource is http://www.connectionstrings.com. For Windows integrated security, look under the heading Trusted Connection. |
 |
|
|
|
|