c#.net MS Access database without Access installed

2019-03-03 17:15发布

问题:

This question already has an answer here:

  • How to open connection with Microsoft Access database in C# 1 answer

Is it possible?

I've tried Google, but I must be searching the wrong key words and not getting an answer.

I have a small application only being used by 2-3 people that I want to store data in a database for. I can't install any SQL servers so I thought access would be the best option.

The computers it will be used on don't have Access installed either.

I'm using VS2012 Express .net4.0

回答1:

Basically all you need is the connection string pointing to the access db with the right provider. Here's one that might work for you, just change the DB location to a shared place that the 2-3 computers can access:

var connection = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\BC207\test.accdb")