1

I have created a Win Form application which adds, updates, deletes records in the database. My application is built in VS 2015 in .Net 4.5 and it uses SQL Server 2012 database for storing records. I have to run this application in another PC that does not have VS nor SQL Server. How to do it?

I have the exe file of my project in the bin folder. So if i run this exe file in another PC, it will start but database operations will not run because SQL server is not there. My Question is how to run my database operations of my project in that another PC now?

yogihosting
  • 5,494
  • 8
  • 47
  • 80
  • Can you show us what the connection string to your data currently looks like please? If it's got something like 'localhost' in it then that will be the issue. – Paul Andrew Jun 07 '16 at 06:52
  • Make an exe and during time of making exe select the components which should be installed on client/other machine – Mairaj Ahmad Jun 07 '16 at 06:54
  • 1
    Are you planning on using the Database located in the original machine? Because you'll need the database deployed somewhere. – Ash Jun 07 '16 at 06:55
  • Open project properties by right-clicking on project. Then go to `Publish` there you will see `Prerequisites` select components which you need. – Mairaj Ahmad Jun 07 '16 at 06:57
  • Are you planning on using the Database located in the original machine or another machine , please let me know? – Nazir Ullah Jun 07 '16 at 07:04
  • the main problem is the database, the client pc does not has database installed i mean (Sql express). Can my exe run without sql express installed in the client pc? – yogihosting Jun 07 '16 at 09:38
  • @NazirUllah i have made the application which has database in sql server 2012. In client system what database should i install - sql server express or sql server express localdb ? – yogihosting Jun 07 '16 at 09:54
  • 1
    the same version 2012(express or local) should install on client system where you install on server . because this give you facility to moving database backup from server to client else compatibility problem will occur during attaching database, if you are not able to install absolutely same version on client machine then no problem just intall any db version and take the script of you database and execute that script on client machine – Nazir Ullah Jun 07 '16 at 10:26
  • Some online tutorials telling that just install SqlLocalDB.MSI in the client pc and the database will start working in the project. Is this true? – yogihosting Jun 07 '16 at 14:32

3 Answers3

1

To answer this, the solution depends on the way you would like to manage your database.

Option 1: The application should execute on separate machine, but you want that the database not to reside on the same machine, and you want to use the same database that is there on other system. If that is the case all you need to do is just change the connection string and provide that of where the databas. Make sure the network is working and you are able to connect to that machine.

Option 2: In case you want to have a separate database for each application instance on the same system, then you need to have some datbase there. If you do not want to install full sql on it you can consider free version like express or some other file base db like sqlite.

Yogi
  • 9,174
  • 2
  • 46
  • 61
  • the problem is it is client pc where the project is to run, the database is also in the client pc. The project has database part where data is stored and retrieved. I want to know if i just install Sql Express Local DB in client pc , will my application will start running on the client pc. ? – yogihosting Jun 07 '16 at 14:36
  • @yogihosting - Yes it will work, provided you do not need the features of full sql sever, which is most probably, you do not need. Sql Express is in itself a very powerful database. Make sure you provide the correct connection in the application, which connects to your sql express database. – Yogi Jun 07 '16 at 14:45
  • Thanks for the info, regarding the connection string. I propose to just provide an installer of my application to the client (by publishing it through VS), and tell him to install SQL local db in his system. So i want to ask when the client will start the installer will the installer automatically make the database (of my application )? or the database will have to be created manually in the client pc? – yogihosting Jun 07 '16 at 15:56
  • @yogihosting - Earlier we used to have a setup and deployment type of project in VS. Wherein you can create the database schema and data along with the installation. Not sure how to do it with vs publish. You can also provide an option in you application to setup database after installation, through a button click or so. Suggest to read more about setup and deployment. You can also consider "install shield" for total control over your installation. – Yogi Jun 07 '16 at 16:18
0

Your application must be someway adaptable to environment, ie. connection string must not be hard-coded. See this article https://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx about storing connection string in configuration file. To help user to create proper connection string for her environment you may include data connection dialog in your app, see Display a ConnectionString dialog

Community
  • 1
  • 1
Serg
  • 22,285
  • 5
  • 21
  • 48
-1

If both systems are connected in same network and you are trying to connect, then you must have sql server on both systems because as far as i know sql server uses It's browser service to connect to another sql server instance.

Another option is Upload your database to web server and connect your application to web database. You can simply do that by uploading your database to server and changing your connection string.

Hope this will help you.