Reputation: 71
I am developing a c# application as College Admission System for some user. User will have to manage records in MS Access databse file attached to c# application. Now i am making an installer for my application in order to install it on user's machine. Solutions i have gone through is: Need to deploy MS Access DB
What i want is that as the application gets installed on user's computer, MS Access database file also should get attached to application. What should i need to do? Is there any beginners approach to that or any guide for this purpose?
UPDATED I have created database file manually and put that file in bin folder right now (and want the same for the user). I just want somehow to get it attached to my application on user's machine, so whenever user will manage records, so records should be added/edited/updated/deleted smoothly.
Upvotes: 1
Views: 681
Reputation: 7862
Have your installer create \ write the database file to a specified directory on the target machine (e.g. AppDataFolder).
When your application starts, test this directory for the presence of the Access database file. If found, create your connection string (see ConnectionStrings.com for help). Consider storing the ConnectionString as a property of your application once you've created it so you don't have to run the same code upon startup next time.
If the Access database file is not located in the directory your installer is supposed to write it to (or your ConnectionString fails) consider prompting the user to locate the file for you (via OpenFileDialog or similar).
Note that it probably isn't a good idea to have your installer write the database file to the Program Files directory since the end user will need to be able to modify the database (and on Vista + this can be problematic due to UAC & permissions).
Upvotes: 1
Reputation: 7
You should use the specific dataBase manager, it deppens of the version of your ms access file these some connection string for oledb ,you can use also odbc 2003 : Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\myDb; Extended Properties=Paradox 5.x;
2007 : Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb; Persist Security Info=False;
Upvotes: 0