473,480 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Server connection string - how do you normally store or build

I just wonder what is/are your practices to build the SQL Server connection
string?
Use object to build the connection string from config file or somewhere?
Sep 12 '08 #1
2 1610
Man T wrote:
I just wonder what is/are your practices to build the SQL Server connection
string?
Use object to build the connection string from config file or somewhere?
Usually you don't build the connection string dynamically. If you need
to connect to different databases you can keep sepearate connection
strings for them or create them from a template with a simple replacement.

The config file is a good place to store a connection string. Then you
don't have to recompile if the database settings change.

--
Göran Andersson
_____
http://www.guffa.com
Sep 12 '08 #2
"Man T" <al**************@yahoo.com.auwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I just wonder what is/are your practices to build the SQL Server connection
string?
Use object to build the connection string from config file or somewhere?
If you are using version 2.0 or above of the Framework, you can use the
SqlConnectionStringBuilder class. You assign values to the various
properties of a SqlConnectionStringBuilder object, and you can then extract
the completed connection string from its ConnextionString property.
This is only needed if you are going to build it on-the-fly from values
that are "found out" during runtime. If the values in the connection string
are known beforehand, it is a common practice to simply store the completed
connection string in a config file.

Sep 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8717
by: Fred Zuckerman | last post by:
Hello All, After reading in this group about the preference for connecting to a SQL Server using a connection string instead of a DSN file, I have done just that. BUT, I cannot update my data....
3
2881
by: Terri | last post by:
When I make change in the Connection screen in an adp I get the message "Your password will not be encrypted before it is saved to the file. Users who view the source contents of the file will be...
12
6628
by: Dave Bailey | last post by:
I need to store an encrypted connection string in the web.config file. I have found several examples on the Net but nothing specific as to how to accomplish task. Thanks in advance, Dave
4
2044
by: jens Jensen | last post by:
Hello, I was given the task to build a .Net client that will talk to IBM integration server via HTTP post. The idea is that each http packet exchange should be authenticated via X09 "client...
2
6914
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
12
2222
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
9
2756
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I...
8
6318
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.