devxlogo

Connecting to an Access DB on a Server

Connecting to an Access DB on a Server

Question:
I want to connect to an Access DB on a server from a client using a VB app. I assume I would have to make a connection to the database on the server. How could I do this? Would I need to return a recordset from the sever via ADO?

Answer:
For Access, you have to specify a directory and filename in your ADO connection string. That means that the directory where the file is located needs to be mapped as a network drive on your computer. Once you’ve done that, you can create your connection string like this:

Dim cnDB As New ADODB.ConnectioncnDB.ConnectionString = _   "Provider=Microsoft.Jet.OLEDB.4.0;" _   & "Data Source=F:MyDB.mdb"cnDB.Open

You can then get recordsets or whatever else you need from the database. If you’re using Access 97, use OLEDB.3.51 instead of OLEDB.4.0 in the connection string.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist