ADODB Local Server Connection

medberg

New Member
Joined
Jul 29, 2011
Messages
30
Hey Everyone,

In my workbook I am trying to connect to a local server using an ADODB conneciton referening the activex data objects 2.8 lib. I am using code that I copied from an old project of mine that works just fine, however it is not working when I modify it to use (local) as the server, rather than an actual server name. The old code is:

Code:
    Dim cnt As ADODB.Connection
    Dim cmd As New ADODB.Command
    Set cnt = New ADODB.Connection
    cnt.ConnectionString = "Provider=SQLNCLI;DATABASE=" + database + ";SERVER=" + server + ";Integrated Security=SSPI;Trusted_Connection=Yes;APP=2007 Microsoft Office system;DataTypeCompatibility=80;"
    cnt.Open
    cmd.ActiveConnection = cnt
    exportQuery = query
    cmd.CommandText = exportQuery
   cmd.Execute

The new code is the same, with (local) replacing server in the above code. Does anyone have any idea as to why this is not working? Is it maybe not possible to connect to a local server using this type of connection? Thanks so much in advance.

-medberg
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
you need to tell it where to look for the database eg
c:\program files\database.mdb

just saying local would be saying somewhere in this computer but im not telling :)
 
Upvote 0
Wow ha...thanks. We had been using SQL Native Client for a couple select statements using (local) and that worked just fine, apparently you can't do the same for ADODB connections though.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top