|
-
Aug 31st, 2008, 04:19 AM
#1
Thread Starter
Fanatic Member
[2005] Connection String
How i can make my connectionstring in sql flexible rather than using this:
Code:
conn.ConnectionString = "Data Source = ServerName; Initial Catalog = DatabaseName; Integrated Security = True;"
If I am going to use this what if i place my application in a other computer that connection string will find the path of the server and the database on the previous computer that i work on.
-
Aug 31st, 2008, 06:32 AM
#2
Re: [2005] Connection String
If you create a Data Source then the IDE offers to put your connection string in the config file by default. Then you only have to edit the config file on each system. Alternatively you can build your connection string using a SqlConnectionStringBuilder, getting the individual properties from wherever you like, e.g. the config file or direct user input.
-
Aug 31st, 2008, 07:42 AM
#3
Thread Starter
Fanatic Member
Re: [2005] Connection String
If you create a Data Source then the IDE offers to put your connection string in the config file by default.
Are you referring on databinding ?
Alternatively you can build your connection string using a SqlConnectionStringBuilder, getting the individual properties from wherever you like, e.g. the config file or direct user input.
How to do that ?
-
Aug 31st, 2008, 02:14 PM
#4
Re: [2005] Connection String
 Originally Posted by aNubies
How to do that ?
build your connection string using a SqlConnectionStringBuilder
and then
getting the individual properties from wherever you like, e.g. the config file or direct user input.
You'll have to be more specific if you want more answers.
-
Aug 31st, 2008, 05:01 PM
#5
New Member
Re: [2005] Connection String
Take a look to SQL ConnectionStringDialog
It is a dll (with source) for displaying a dialog for connecting, browse the database, create the connectionstring, test it, and save the string to the application settings.
In my apps I try a connection in the load event. If fails, then I open a SQLConnectionDialog.
Additionnally, there is a OLEDb connection dialog, so I have modified the class for connecting to access databases.
Alex
-
Aug 31st, 2008, 06:18 PM
#6
Re: [2005] Connection String
 Originally Posted by aNubies
Are you referring on databinding ?
No, I'm referring to creating a Data Source froem either the Data Sources window or the main menu. That will add an entry to your Data Sources window and create a corresponding typed DataSet class. You can then create instances of that class in code, which might then be bound to your controls. Data-binding is not limited to DataSets though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|