简体   繁体   中英

Connecting to a Microsoft Access database from C#

I'm working on a project in C#, which includes a Log in form, however as of yet I haven't managed to get the connection working. My

OleDBConnection

object has the connection string

@"Provider=SQLOLEDB;" + @"Data Source=" + Assembly.GetExecutingAssembly().CodeBase + "DATABASE_NAME.accdb" + @"Persist Security Info=False;"

( Messy I know )

Note: I have tried other providers

Microsoft.Jet.4.0
Microsoft.ACE.12.0

both with no avail. I'm just trying to connect my C# code to the Access database which is in it's Debug folder.

Thanks for the help.

If you haven't heard of ConnectionString, it very handy website to find correct connection string for any provider.

https://www.connectionstrings.com/

One thing to note is, not all the provider driver may be installed on your computer, so you need to install them first before using that provider.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM