MS Access and Visual Studio?
Hello, I'm trying to develop a small app that uses an Access Database file. I know EF and Datasets aren't really built to support Access, but in my case i don't have an option to switch over to SQL Server. I want to know what would be the best method to use to link my database to my c# project so that I can query results from my project app. Could someone point me to some tutorials or something? Thank you.
- 6 years agoFavorite Answer
Nearly every tutorial out there uses the Northwind Access MDB as the database to connect to when using VS. Your connection string to the data is all that will really change.
Just go to the Serve explorer and add a new connection. IN the provider dialog click on the MS Jet 4.0 OLE DB provider and then browse for your access mdb file. Type in the USER ID and PW (if any) you use to access the MDB file and you should have full access to the data base from within your project.
You can also drag and OleDbConnection object right onto any form or desginer and set the connection String prop to connect to your MDB.
IN code you can connect using the System.Data.OleDb.OleDbConnection object.
A connection string for access will look something like this
@"Data source= C:\Documents and Settings\username\My Documents\AccessFile.mdb";
just remember the you will need to .Open() your connection and when you are done you should .Close() the connection immediately!
Hope this helps...
- The WandererLv 66 years ago
Yeah, your going to have top use ADO... here is a link to some examples...