web.config in WinForms

  • Thread starter Thread starter Bruno Alexandre
  • Start date Start date
B

Bruno Alexandre

Hi guys,

I'm a asp.net 2.0 programmer and I'm creating my first applications, but I
need to ask you one question.

in ASP.NET 2.0 our DB string is placed under web.config and then we can
access it using

ConfigurationManager.ConnectionStrings("myConnection").ConnectionString


and how about in Window Forms? where can I have such place? not using a
class and put the string there and then call the class everytime ;-)


--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
Right click the project and select Properties. Put
your setting in the Setting section. VS.NET will
create intellisense directly to the property name.
Syntax to reference it would be something like:

NameSpace.Settings.PropertyName

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
 
Hello Bruno,
Hi guys,

I'm a asp.net 2.0 programmer and I'm creating my first applications,
but I need to ask you one question.

in ASP.NET 2.0 our DB string is placed under web.config and then we
can access it using

ConfigurationManager.ConnectionStrings("myConnection").ConnectionStrin
g

and how about in Window Forms? where can I have such place? not using
a class and put the string there and then call the class everytime ;-)

The winform equivalent of the web.config file is the app.config. When you
compile your executable, the app.config will be renamed to yourapp.exe.config
(where yourapp is the name of your executable file). Note, if you are including
the username and password in the config file, unlike ASP which denies external
access to the web.config file, your users will have direct access to your
..config file. Thus, you may want to consider encrypting the connection string.
The same holds true if you wish to use the .Settings file rather than the
..Config file.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
:-) nicely reminder...

I found some tutorial in Encrypt the Connection String in Asp.NET
I will have a go in implement the same method under vb.net

Thank you Jim

--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
Back
Top