Click here to Skip to main content
Rate this: bad
good
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
digimanus28.9K
v2
Comments
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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 467
1 CPallini 400
2 Sergey Alexandrovich Kryukov 348
3 BillWoodruff 254
4 George Jonsson 251
0 OriginalGriff 5,370
1 CPallini 4,360
2 Sergey Alexandrovich Kryukov 3,822
3 George Jonsson 3,037
4 Gihan Liyanage 2,435


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100