You are correct , for some reason Windows only authentication was selected.
you are half way, could you give me an answer for the rest of the question?
thanks
Main Topics
Browse All TopicsI have 02 different procedures I pasted below. My questions are:
1 - In which circumstances should I use
cn.ConnectionString = "DSN=MyDataSource;Uid=sa;P
OR
cn.ConnectionString = "Provider=sqloledb;" & _
"Data Source=computer1;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password="
2 - when I use :cn.ConnectionString = "DSN=MyDataSource;Uid=sa;P
It works fine.
But When I use:
cn.ConnectionString = "Provider=sqloledb;" & _
"Data Source=computer1;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password="
It gives me an error logon failed for a user "sa" Reason not associated with SQL server Connection.
Even when I changed User Id= administrator it gives me the same error:logon failed for a user "administrator" Reason not associated with SQL server Connection.
Though I am logging as a domain administrator to the machine where MSAccess is installed and it is the same account I logged on to the domain controller where sql server is installed.
thanks
Private Sub Command5_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Set cn = New ADODB.Connection
cn.ConnectionString = "DSN=MyDataSource;Uid=sa;P
cn.Open
strSQL = "Select * from authors where au_lname = 'Ringer' "
Set rs = cn.Execute(strSQL)
Do While Not rs.EOF
MsgBox (rs!au_lname & " " & rs!au_ID)
rs.MoveNext
Loop
MsgBox ("END OF FILE NOW")
End Sub
**************************
Private Sub Command6_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=sqloledb;" & _
"Data Source=computer1;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password="
cn.Open
strSQL = "Select * from authors"
Set rs = cn.Execute(strSQL)
MsgBox (rs!au_lname)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Do you mean when to use ODBC or native data providers..?
My answer to that is simple. Never use a DSN when connecting to SQL Server. There are a couple of reasons:
1. You can't pass the Database and Server name to your connection string using ODBC. These parameters are important if you plan to make use of a login screen and have a multi-server / database environment.
2. Using ODBC means that you need the DSN setup on EVERY client machine you intend to install your application on.
3. Native data providers will generally return faster results than ODBC.
Hope that answers your question.
Jack
from what I have understood (Please,Correct me if I am wrong)
1- when we use : cn.ConnectionString = "DSN=MyDataSource;Uid=sa;P
that means we have to use the wizard first to set up the datasource name on each machine that has Access on it in order to connect to sql server
2- when we use : cn.ConnectionString = "Provider=sqloledb;" & _
"Data Source=computer1;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password="
that means we don't have to set up DSN with the wizard, and this works with ActiveX component set as reference in Access.
3- Well I have noticed the usage of
cn.ConnectionString = "Provider=sqloledb;" & _
"Data Source=computer1;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password="
AND SOMETIMES
con.ConnectionString = "Provider=MSDASQL.1;Persis
(In this case, we still have to set up the DSN through the wizard. Correct ? (as you mentioned ISKPatel) )
what's the difference between the 02 methods?
some explanation tha clears up the confusion will be very much appreciated.
thanks
1. Yes, when you specify a DSN in the connection string it must exist on the client machine.
2. That is also correct (no DSN is required where using the OLEDB provider) but this looks to me like a connection to SQL Server. What is the relation to Access..?
3. Basically you have two different Data Providers in these examples:
* SQLOLEDB is one of the two Microsoft standards for generic data access (the other being ODBC)
* MSDASQL is basically the OLE DB wrapper for ODBC. What this means is that it exposes ODBC functionality using the OLE DB API's. For this to work it includes a translation layer and therefore some extra overheads.
Are you trying to connect to Access and to SQL Server in your application..? If you want a recommendation here it is:
Access: "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\somepath\m
SQL Server: "Provider=SQLOLEDB.1;Data Source=SERVER_NAME;Initial
Using these two connection strings you avoid having to create a DSN for either data source.
Jack
To TDSnet :
I use MSAccess to connect to SQL server 2000. I have noticed in some examples I looked on the internet that there are different ways to connect to SQL server from MSAccess, let me mention some of them to you, and correct me if I am wrong in defining their roles:
1 -We can Install ODBC DSN on the Machine where MSAccess is running, and write a VBA code to query SQL server, we use the following connection.
cn.ConnectionString = "DSN=MyDataSource;Uid=sa;P
*** I don't know if we can query sql server with just a query NO VBA ***, example please.
2- we can connect from MSAccess to SQL server using the following Connection:
cn.ConnectionString = "Provider=sqloledb;" & _
"Data Source=computer1;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password="
In this case, we don't have to install ODBC in MSAccess Machine. Correct?
3- we can also use the following connection
con.ConnectionString = "Provider=MSDASQL.1;Persis
I guess here we need to install ODBC in MSACCess Machine. If so , what's the difference betwen method 1 and method 3. if no( we don't have to install ODBC in method 3), so please tell me the difference between method 2 and method 3.
thanks
Business Accounts
Answer for Membership
by: TDSnetPosted on 2005-05-18 at 18:11:10ID: 14032694
Hi,
What is your authentication mode set to on your SQL server..? In Enterprise Manager, right click on the server name, click on Properties, go to Security tab. Select the radio box "SQL Server and Windows" under Authentication.
Cheers,
Jack