Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#3.0
I want to make setup of my windows application I am using sqlserver2008 as database server.
I have created Library named DBConnection for connection with database and using connection string from App.config file.
so how can put database in setup project to attach to server of client where this project is installed.
My ConnectionString is:
in cs file
 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[0].ConnectionString.ToString());
and in App.config
<add name="Conn" connectionstring="Data Source=GANGARAM-PC\SQLEXPRESS;Initial Catalog=Ganga;Integrated Security=True" providername="System.Data.SqlClient" />

Plz give solution.
Posted 17-Sep-11 8:29am
Edited 17-Sep-11 8:34am
digimanus at 17-Sep-11 14:36pm
Just a TIP: where you state [0] for the connectionnumber you can better name it by using ["Conn"]. If someone install mysql server on the same machine you project start looking at mysqlserver with sqlserver instances. That definately will go wrong. By using the name you prevent this problem

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

do a bit of searching and you will find solutions - such as here
What I did in my last project was to leave the connections string with a non valid value in the config, and my application checked it at start up and invoked a connections string editing form if it was invalid.
This has the advantage that, should the client need to change the location of their database, the application has the functionality available to change the connection string.

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

  Print Answers RSS
Your Filters
0 Shai Vashdi 1,628
1 Tadit Dash 375
2 Manas Bhardwaj 319
3 Sergey Alexandrovich Kryukov 275
4 OriginalGriff 243
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,711
2 Peter Leow 4,320
3 Maciej Los 3,540
4 Abhinav S 3,373

Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 19 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid