473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Connection string in app.config (not in web app)?

Like a web app can store its connection string in the web.config file, can a
windows forms or console app or windows service store its connection string
in app.config?

Is it advisable?
I know the web application is best to store its strings in there as the web
server will flatly refuse to serve up that file, but I've heard that it will
server up an aspx file if you ask for $::myfile.aspx$ or something like that.
But for a winapp, is it just easier to have a class called 'consts' and have
static strings in that?

Or is it the 'done thing' to use application configuration settings?

Please advise

Thanks
Nov 16 '05 #1
6 15393
Hi,

Hard-coding the connection string is probably not a good idea - should
connection parameters change and you are bound to re-build and re-deploy the
application. Therefore, storing the connection string in app.config is
advisable. If you care about the security, you can store it encrypted and
probably digitally signed.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
Like a web app can store its connection string in the web.config file, can
a
windows forms or console app or windows service store its connection
string
in app.config?

Is it advisable?
I know the web application is best to store its strings in there as the
web
server will flatly refuse to serve up that file, but I've heard that it
will
server up an aspx file if you ask for $::myfile.aspx$ or something like
that.
But for a winapp, is it just easier to have a class called 'consts' and
have
static strings in that?

Or is it the 'done thing' to use application configuration settings?

Please advise

Thanks


Nov 16 '05 #2

Hard-coding the connection string is probably not a good idea - should
connection parameters change and you are bound to re-build and re-deploy
the application. Therefore, storing the connection string in app.config is
advisable.
Is this an app.config that has to remain in the same folder as the .exe when
it is running, or is compiled into it? I don't want something that's not
embedded into the .exe file.
If you care about the security, you can store it encrypted and probably
digitally signed.


How do I do this, and how do I connect the app.config to the program in the
first place? I don't posess any "certificates" if that's what you mean.
Nov 16 '05 #3
I believe the security hole you refer to was only in the classic ASP
days, there was an issue where IIS would serve the actual contents of
the file (ie. code) if you used some wierd NTFS syntax to request the
file.

And yes, if you're concerned about security, please encrypt the
connection string.

Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

"Bonj" <Bo**@discussions.microsoft.com> wrote in message news:<0B**********************************@microso ft.com>...
Like a web app can store its connection string in the web.config file, can a
windows forms or console app or windows service store its connection string
in app.config?

Is it advisable?
I know the web application is best to store its strings in there as the web
server will flatly refuse to serve up that file, but I've heard that it will
server up an aspx file if you ask for $::myfile.aspx$ or something like that.
But for a winapp, is it just easier to have a class called 'consts' and have
static strings in that?

Or is it the 'done thing' to use application configuration settings?

Please advise

Thanks

Nov 16 '05 #4
The app.config is not embedded, it lives in the same folder.

WinForms and Console apps will generally use the user's credentials
when connecting, or prompt the user for credentials if the database
does not accept Windows logins. Generally all you'll need in the
config file then is the parameters like server name, port, database
name, etc.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 29 Nov 2004 18:45:44 -0000, "Bonj" <benjtaylor at hotpop d0t
com> wrote:

Hard-coding the connection string is probably not a good idea - should
connection parameters change and you are bound to re-build and re-deploy
the application. Therefore, storing the connection string in app.config is
advisable.


Is this an app.config that has to remain in the same folder as the .exe when
it is running, or is compiled into it? I don't want something that's not
embedded into the .exe file.
If you care about the security, you can store it encrypted and probably
digitally signed.


How do I do this, and how do I connect the app.config to the program in the
first place? I don't posess any "certificates" if that's what you mean.


Nov 16 '05 #5
yeah, true.
I don't want the reliance on a text file living in the same directory, so I
might aswell just hardcode it into a "Consts" class.... Don't ask me why - I
guess some users might think it's a log file and delete it.

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:56********************************@4ax.com...
The app.config is not embedded, it lives in the same folder.

WinForms and Console apps will generally use the user's credentials
when connecting, or prompt the user for credentials if the database
does not accept Windows logins. Generally all you'll need in the
config file then is the parameters like server name, port, database
name, etc.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 29 Nov 2004 18:45:44 -0000, "Bonj" <benjtaylor at hotpop d0t
com> wrote:

Hard-coding the connection string is probably not a good idea - should
connection parameters change and you are bound to re-build and re-deploy
the application. Therefore, storing the connection string in app.config
is
advisable.


Is this an app.config that has to remain in the same folder as the .exe
when
it is running, or is compiled into it? I don't want something that's not
embedded into the .exe file.
If you care about the security, you can store it encrypted and probably
digitally signed.


How do I do this, and how do I connect the app.config to the program in
the
first place? I don't posess any "certificates" if that's what you mean.

Nov 16 '05 #6

"Joel Martinez" <jd********@ea.com> wrote in message
news:29************************@posting.google.com ...
I believe the security hole you refer to was only in the classic ASP
days, there was an issue where IIS would serve the actual contents of
the file (ie. code) if you used some wierd NTFS syntax to request the
file.


yes, that's it... comical how they could have let it slip really.
Nov 16 '05 #7

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

Similar topics

3
by: Varun | last post by:
I have a solution which contains windows,web,mobile presentations. Now i want to share the connection string in the web.config file. i want to write a method in a common layer where i can retrieve...
12
by: Charlie | last post by:
Hi: My host will not allow me use a trusted connection or make registry setting, so I'm stuck trying find a way to hide connection string which will be stored in web.config file. If I encrypt...
19
by: Jaime Stuardo | last post by:
Hi all.. I have created a business logic component that is used from my ASP.NET webform. It works, but connection string to the database is hard coded, as in this method : public DataSet...
6
by: Bala Nagarajan | last post by:
Hello, I am using Oracle 9i in my application and facing a problem with the connection string. In the datasource attribute of the connection string i had to specify an entry in "tnsnames.ora"...
1
by: amber | last post by:
Hello, I've just upgraded from .NET 2003 to 2005 and to SQL Server Express 2005. I've rebuilt my connection string. Before I used app.config, and now have the connection string is in the...
14
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review,...
4
by: Matt Colegrove | last post by:
I'm working on a web app that is published to a hosting service. I'm developing it on my local PC with VS 2005 and SQL Express. The hosting service DB is SQL Server 2000. I have two...
2
by: Thorsten Dittmar | last post by:
Hi, I don't get it. I'm using a typed dataset with table adapters and all that stuff. I have the database server running locally on my development system. Now: when creating a tableadapter...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.