Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
i have created a simple window form application project that have only 2 form..
1st one for login in which it'll check the userid n password from database.if both are correct then it will go to 2nd form.
now i want this project to run in another computer.
i created a setup file but its showing some error regarding the database instances connection..
so if anyone can tell me in details how to create the setup file then it'll b a great help..
thanx in advance..
Posted
Comments
Murugan Kolanji 19-Dec-13 14:42pm    
Check your connection string properly. Make sure the DB is in the same system, if not mention the DB pc ip / name in the connection string.
Member 10438743 20-Dec-13 2:41am    
i want to make it like a software.i mean anyone can take this exe file and install it in their system and use the contents.they have the sqlserver or not that doesn't matter..

First check your connection string if u use your computer's name as the datasource then change it as Data Source=.\sqlexpress, While creating setup file you need to select SQL Server under the required prerequisites option also u should use installer class which contains code to restore DB(refer this article for creating installer class for restoring DB Restoring SQL Server Express 2008 Database with Click Once[^]).Then install your application in the other system
 
Share this answer
 
If a second computer uses Windows OS, then you don't need to install your application on that computer. Just copy executable file ;)

If you use SQL server database and want to connect it via LAN, you need to enable SQL Server TCP/IP connections[^].

Remember to check connection string as Murugan Kolanji mentioned.

Next time, please be more specific and provide more details.
 
Share this answer
 
Attach sql database file to creating .exe setup in c# :-

We can implement auto attach database just use the connection string following.

1) Add a folder named ”DB” to the project, and copy the database file into it after you detach it from your sql server.
2) Change your connection string like this:
<connectionstrings>
<add name="WindowsFormsApplication1.Properties.Settings.BabakConnectionString">
connectionString="Data Source=.;AttachDbFilename=|DataDirectory|\DB\Babak.mdf;Initial Catalog=test;Integrated Security=True"
providerName="System.Data.SqlClient" />


3) After these, the database file will auto attach to the sql server when you run your application, and the database name is “test”, you can open the sql server management studio to find it.

In addition, you can find the connection in the app.config file through the solution explorer in vs2010. And you also can find this file under your project. With these information, you can find it and modify it.
 
Share this answer
 
You need to get the connection string right, as others have said. Really, you should not expect to find it automatically, but rather to allow a user to configure it ( although you can guess what it might be ) and install your database from an admin console in your app.

Your other option is to use SQL Server Compact Edition, which does not require SQL Server to be installed and thus makes deployment much easier.
 
Share this answer
 
Comments
Member 13194109 21-Jul-18 10:31am    
pls how can I add database file into during creating setup in visual studio 2015

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900