ADO connection to Network share

How would I create an ADO connection within Visual Basic 6 to an Access db on a Network share, i.e. \\SomeServer\SomeShare\SomeAccess.mdb?  The share requires a login and password, so I assume the ADO connection would have to accommodate this, but how?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Check this web site for ADO connect strings:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arichexeAuthor Commented:
I used's example below, but could never get it to work.  I think the problem is that the network share requires a login.  The login in the example below is for the database, not the share, I think.  I'm beginning to think I'll need to dynamically map a drive, before I attempt to connect, which will be really hairy.

oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
                  "Dbq=\\myServer\myShare\myPath\myDb.mdb;" & _
                  "Uid=admin;" & _

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Guess you found the solution :-) The database needs to be "reachable" and thus the login to the networkshare has to be arranged before building the connection.

arichexeAuthor Commented:
Is there anyway to automate the login to the share?
Alan WarrenApplications DeveloperCommented:
Hi arichexe

Can you browse to 'myServer\myShare\myPath\myDb.mdb' from your pc?
If you can, then it is reachable. Simple test: paste the path into an explorer address bar and hit enter \\myServer\myShare\myPath\

The folder must have modify permissions assigned for users/groups you wish to access this resource.
For the sake of testing the following, I gave Everyone modify permissions on the network folder that contains the db.

' This works on my network.

Sub someSub()
  Dim objRs As ADODB.Recordset
  Dim objCn As ADODB.Connection
  Dim strSql As String
  Dim strDataConnect As String
  Dim strDataPath As String
  strDataPath = "\\Mordor\shared\Data\Northwind.mdb"
  strDataConnect = adoConnectJet40(strDataPath, "password")
  Set objCn = New ADODB.Connection
  objCn.Open strDataConnect
  strSql = "select * from Employees"
  Set objRs = New ADODB.Recordset
  objRs.Open strSql, objCn, adOpenForwardOnly, adLockReadOnly
  With objRs
    While Not .EOF
      Debug.Print .Fields(0)
  End With
  Set objRs = Nothing
  Set objCn = Nothing
End Sub

Public Function adoConnectJet40(psDataPath, psFilePassword)
  ' returns Jet 4.0 ADO connect string:
  '   "Provider=Microsoft.Jet.OLEDB.4.0
  '     ;Data Source=C:\xxx\Some.mdb
  '     ;Jet OLEDB:Database Password=xxx"
  Dim sProvider, sDataSource, sDBPassword

  sProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
  sDataSource = ";Data Source=" & psDataPath
  If psFilePassword = "" Then
    sDBPassword = ""
    sDBPassword = ";Jet OLEDB:Database Password=" & psFilePassword
  End If

  adoConnectJet40 = sProvider & sDataSource & sDBPassword

End Function

Take care...

arichexeAuthor Commented:
Don't I need to send a user id along with the passowrd?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.