Click here to Skip to main content
15,662,754 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to connect to a Remote MS Access Database which is located on a remote machine. I was thinking of doing it either with the ip address (\\\mydb\acc.mdb) or through the machine name (like \\mymachine\mydb\acc.mdb)

Can anyone please guide me as how we can do this and help me with the string required to connect to a remote database?


First, if you have a choice, don't use VB6 which is a legacy environment. So if possible shift to VB.NET.

Secondly, Access is basically just a flat file so what you need is access to the file itself. You can map the share using both IP or UNC or use the file without mapping.

Thirdly, you didn't mention the technology you want to use. If you are really required to use VB6, I think ADO would be the logical choice. Here's one tutorial how to connect to an Access database with ODBC using ADO:[^]
Share this answer
ankitjoshi24 4-Apr-11 15:57pm    

Thanks for the reply. I could get through the link you have sent.

And I will be using ADO connectivity.

I will try using the solution provided in the link and will let you know if this works.

Also if you have any other solution to this problem, please let me know. It will be an extra help.

ankitjoshi24 4-Apr-11 15:59pm    
Just one question I had,

Does this help my client to connect to the database which is on the server machine???

I want my client to connect remotely to the database store on my server machine. And the client would not be working on the same machine as the server.

Wendelius 4-Apr-11 16:11pm    
Yes it does. Access is basically just a file, not a full-blooded database server. You can compare Access to an Excel file. As long as you have the privileges to see and open the file for editing, you can connect to it using for example an ODBC driver (and ADO).
Sergey Alexandrovich Kryukov 4-Apr-11 21:49pm    
#1: don't use VB, #2: don't use Access...
Mika, the Answer is adequate, my 5.
ankitjoshi24 5-Apr-11 16:23pm    
BTW, did anyone try my solution which I have posted??? and does anyone have a better way of doing it???
Hi all

I found a solution for this thing,

You got to put your database in a shared folder e.g: C:\SharedFolder\database.mdb where your "SharedFolder" is shared.

Now supposed the ip address of your computer is then you can access it from VB6 using: -

Public cn As ADODB.Connection
Public rs As ADODB.Recordset

Public Function DBConnect()

On Error GoTo openErr

'Dim cn As ADODB.Connection
'Dim rs As ADODB.Recordset

Dim MSDatabase As String

'MSDatabase = App.Path & "\" & "database.mdb" 'This works

MSDatabase = "\\\SharedFolder\database.mdb"

Set cn = New ADODB.Connection

cn.CursorLocation = adUseClient
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open MSDatabase, Admin
MsgBox "Database connected"
Exit Function
MsgBox "Databae not connected"
End Function

Hope this helps everyone who are facing the same problem


Share this answer
evry1falls 18-Nov-13 17:06pm    
I know this solution, I've read it before on 2 different websites and it worked for me ... But using shared folder to connect to a database will not be the best solution with Multi-users connect at the same time. Since there is an offline mode in [DataSet], it made it more efficient to work with multi-users. I'm using this solution along with Ado.Net in my work, and is working like a charm.
Here is the source I've read this at []
Dim cn As Object
Dim rst As Object
Dim strConnection As String
Dim strSql As String

Set cn = CreateObject("ADODB.Connection")
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & "path of the file" & "Data.mdb"
strSql = "SELECT * FROM User_Login where User_Id=’username';"
cn.Open strConnection
Set rst = cn.Execute(strSql)

If rst.BOF And rst.EOF Then
MsgBox "No data found"
Exit Sub
uname1 = Trim(rst.Fields(0))
pwd1 = Trim(rst.Fields(1))
End If

Set rst = Nothing
Set cn = Nothing

refer this for more details
Share this answer
CHill60 22-Dec-14 9:41am    
Question is 3 years old and resolved.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900