Connect to SQL Server over a network using ADO from Excel VBA

I need to connect to a SQL Server database running on my laptop from another computer on the network. I do this from both a C # application and a VBA macro. Both work fine on my laptop, and the C # application works fine over the network. However, I cannot connect to VBA through the network. This is my connection string:

ConnectionString = "Driver={SQL Server};Server=MY-LAPTOP; DAtabase=SAFEXlive; UID = MyUsername; PWD=MyPassword"

Apart from "Driver = {SQL Server}", it is the same as the connection string that I use in a C # application that works.

Then I use the following code (with reference to the Microsoft ActiveX Data Objects 6.0 Library in VBE) to open the connection:

Dim oConnection As Connection
Set oConnection = New Connection
oConnection.ConnectionString = strConnectionString
oConnection.Open

, , , : " " -2147217843 (80040e4d) [Microsoft] [ ODBC] [SQL Server] ... ", , .

- , excel? ? ?

+3
2

. . UID. ...UID= MyUsername;... ..UID=MyUsername;..., .. , , ! .

+3

,

ConnectionString = "Provider=SQLOLEDB;Data Source=MY-LAPTOP;Initial Catalog=SAFEXlive;User ID=MyUsername;Password=MyPassword"

AD? , , , domain\user. .

+2

All Articles