Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ADO connection to Network share

Posted on 2004-10-29
9
Medium Priority
?
224 Views
Last Modified: 2008-02-26
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?
0
Comment
Question by:arichexe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 12450859
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 336 total points
ID: 12451053
Check this web site for ADO connect strings:

http://www.able-consulting.com/ADO_Conn.htm
0
 

Author Comment

by:arichexe
ID: 12453468
I used www.able-consulting.com'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;" & _
                  "Pwd="


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 54

Assisted Solution

by:nico5038
nico5038 earned 332 total points
ID: 12453671
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.

Nic;o)
0
 

Author Comment

by:arichexe
ID: 12454294
Is there anyway to automate the login to the share?
0
 
LVL 26

Assisted Solution

by:Alan Warren
Alan Warren earned 332 total points
ID: 12454786
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)
      .MoveNext
    Wend
    .Close
  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 = ""
  Else
    sDBPassword = ";Jet OLEDB:Database Password=" & psFilePassword
  End If

  adoConnectJet40 = sProvider & sDataSource & sDBPassword

End Function


Take care...


Alan
0
 

Author Comment

by:arichexe
ID: 12487133
Don't I need to send a user id along with the passowrd?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question