user2098816
user2098816

Reputation: 1

Automatically install access database when creating setup file in c#

I Have created a c# application which is using access database.
I have deploy the application successfully.
what I want is install the access database automatically in other users computer automatically.

I have tried to change the app.config files connection string and no use..:(
help me

Upvotes: 0

Views: 7233

Answers (4)

Pir Fahim Shah
Pir Fahim Shah

Reputation: 10623

If you want to create .exe Setup Project of your Dot Net Application which is using MS Access DATA BASES. then simply follow this steps. Please read this one for a moment before to proceed these steps.Connect with MS Access Data Base in Dot net. When you are going to create the exe file then your data base connection string should be like this(means there should be no directory in @"Data source, Just direct put the name of your data base, because in .exe file when you add your data base file, then it is in the same directory.

   System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
    conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
     @"Data source=MyDataBase.accdb";
  1. Right click on your solution file. (like in Solution Explorer "Solution 'MyProject' ")
  2. Select Add -->New Project -->Other Project Types
  3. Select "Setup"
  4. A New project will be added named setup (with a new tab added to editor as File System )
  5. Now right click on application folder -->select add -->select folder new folder will be added under application folder * Now Right click on newly added folder -->select add -->select file * Add File dialog will be popup
  6. Select your Db file (means from a "Browse" Button there go and select your Access Data Base )
  7. Select Setup project and build.. Now your installer will have your DB.
  8. You can also install it from there.

Upvotes: 0

user1064248
user1064248

Reputation:

Copy the access db to a folder in programdata with the setup. Connect to this db in your code. You don't need a connectionstring in app.config if the user is not allowed to specify the db path.

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

Your setup should be able to deploy to a programdata folder.

Upvotes: 0

Alina B.
Alina B.

Reputation: 1276

Not sure what you mean, but if your database is part of your solution you can copy it to the output directory:

enter image description here

Upvotes: 1

Related Questions