1

I have develop a desktop application in .NETFramework, Version=v4.5 using visual studio and database using SQL sever express 2014. My app is ready. Now I have to install it on client machine. how can i create database there?

which features of SQL express i have to install on client machine?

Please provide me an easy solution.

hassan mirza
  • 139
  • 2
  • 8
  • 1
    use a MDF file, that's small and better way to deploy desktop app. – Anirudha Gupta Aug 22 '17 at 07:26
  • 1
    which ever ones you use! – BugFinder Aug 22 '17 at 07:26
  • a database for a desktop app? – Marco Salerno Aug 22 '17 at 07:29
  • 1
    If you need a database locally which will not be accessed by other machines then maybe SQLite is a better approach? – jason.kaisersmith Aug 22 '17 at 07:30
  • @MarcoSalerno Why not? How else would you deal with having to keep a lot of data? – Fildor Aug 22 '17 at 07:42
  • Usually if the user has to store data inside his own computer you find a way to store those information, but not by installing a db lol – Marco Salerno Aug 22 '17 at 07:44
  • "how can i create database there?" - You either create your Dbs Tables and so on in code by checking on startup if they exist - or you import an empty template db. – Fildor Aug 22 '17 at 07:44
  • @MarcoSalerno I admit that instaling an SQL Server Express locally may seem overkill but you don't know the appliance. For certain types of Applications this would be not uncommon. – Fildor Aug 22 '17 at 07:48
  • Well yes, obviously but depends from the type of application – Marco Salerno Aug 22 '17 at 07:49
  • That's what I am saying. – Fildor Aug 22 '17 at 07:49
  • @jason.kaisersmith , Now, i have to install sqllite and use sql script to create data base in client machine. – hassan mirza Aug 22 '17 at 08:14
  • @AnirudhaGupta , MDF is Database file. when i try to copy it from my PC , SQL take permission. After allowing permission, How can I use it on client machine?? Path of MDF file would be different in my PC and Client PC. ExE file will not get MDF file path. – hassan mirza Aug 22 '17 at 08:19
  • @MarcoSalerno, Yes Database for desktop app. How can i deal with database on client machine with no SQL etc. If I have to install SQL server/ SQLite , Which features I have to install, just for creating DB. Ofcourse, I do not have to install complete SQL server with management studio. please give me any direction – hassan mirza Aug 22 '17 at 08:22
  • @hassanmirza you can't modify files in Program Files Once you install it there use AppData. – Anirudha Gupta Aug 22 '17 at 08:28
  • @Fildor , Visual studio creates .exe file, which runs smoothly on my machine, as it finds database. When I copy it to client PC, .EXE file runs , but cannot proceeds as it does not find .MDF(database file). How can I create Table and procedures there?? – hassan mirza Aug 22 '17 at 08:28
  • @AnirudhaGupta , Yes you are right. When .Exe file run on client machine, it does not find database and its path, which it has on my machine. what i have to do now?? Should I install SQL Server on client machine too??? If yes, which features of SQL for just to run database file. – hassan mirza Aug 22 '17 at 08:33
  • @hassanmirza see this https://stackoverflow.com/a/9561643/713789 – Anirudha Gupta Aug 22 '17 at 08:34
  • @hassanmirza see ApplicationData on this https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx – Anirudha Gupta Aug 22 '17 at 08:35

3 Answers3

1

You can use following strategy to make it work.

Copy the database file from program Files to AppData on installation of the software. You can't modify the files in Program Files that's why you need to have it in AppData.

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79
0

From the developer machine, create a backup file of the database and use this backup to restore the db on the client machine. The client machine will need to have SQL Server Express installed and you will need to adjust the connection string accordingly.

dalix
  • 1
  • 1
0

Creating a backup as mentioned above is simplest.

I've found it helpful (as I develop) to maintain a TSQL script. The script will drop the tables and indexes...recreate and even populate.

Chris Catignani
  • 5,040
  • 16
  • 42
  • 49