jking1234
asked on
oledb connection to SQL Server not working
In Access 2007, (trying to access SQL Server) I have the following code:
Dim cn As New ADODB.Connection
Dim strCN As String
strCN = "Provider=SQLOLEDB;Server= 10.10.10.1 ;" & _
"Initial Catalog='Websites';User ID=sa;PWD=xxxxxxxx"
cn.CommandTimeout = 3000000
cn.Open
This gives the following error:
[Microsoft][ODBSC Driver Manager] Data Source Name not found and no default driver specified
Dim cn As New ADODB.Connection
Dim strCN As String
strCN = "Provider=SQLOLEDB;Server=
"Initial Catalog='Websites';User ID=sa;PWD=xxxxxxxx"
cn.CommandTimeout = 3000000
cn.Open
This gives the following error:
[Microsoft][ODBSC Driver Manager] Data Source Name not found and no default driver specified
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
zzz
I would recommend to use the SQLNCLI driver instead (must be installed on Windows XP machines, not available by default).
Moreover you should make sure that TCP/IP is enabled on the SQL Server if you access the server by IP address.
You can find examples of connection strings here:
http://www.connectionstrings.com/sql-server-2005#p2
There is also an example of how to use the IP address.
And I hope that this string was only an example and you don't really try to connect to the SQL Server using the "sa" account...:-)
Cheers,
Christian