Discussions Search    Reviews    Search Aid    Buzzzz    Google@Omgili Add to iGoogle   Bookmark and Share

  Advanced Search



Reading connection string from my App.Config file

On Thu, 3 Jul 2008 10:03:55 +0500, "Abul Hasan Lakhani" <...@ecsonline.com.pk

Hello

This is my first post to this group. I just want to ask that how will I read
my connection string from the app.config file in C# 2008 and .Net 3.5. I
tried to use System.Configuration namespace but I think missing something.

here is my app.config file

-------------------------------------------------------------------------------- ---------------------------------
<?xml version="1.0" encoding="utf-8" ?<configuration <configSections </configSections <connectionStrings <add
name="Containers.Properties.Settings.Custom_JobConnectionString"
connectionString="Data Source=196.3.3.3;Initial
Catalog=Custom-Job;User ID=sa;Password=altsds"
providerName="System.Data.SqlClient" / </connectionStrings</configuration---------------------------------------- ---------------------------------------------------------------------------

Thanks in Advance


Abul Hasan Lakhani.

 Latest discussions from this group  (microsoft.public.dotnet.languages.csharp)

Re: Problem extending Object  
[28 Aug 2008]
On 28 Aug 2008 00:44:57 GMT, J. Moreno <planb@newsreader s.com Since nobody seems to know...
know the answer in the vb group, guess I'll ask here... Does anyone know why I would be able...
No image in firefox  
[27 Aug 2008]
On Wed, 27 Aug 2008 06:31:00 -0700, Rui Oliveira <RuiOliveira@disc ussions.microsoft.co m...
I have the following code to show an image in html: "   :.. <img src=\"...
XXXBindingSource  
[27 Aug 2008]
On Wed, 27 Aug 2008 14:33:13 +0200, "Tony Johansson" <johansson.anders son@telia.com Hello...
Hello! What purpose does this object have ? //Tony
More...


On Wed, 02 Jul 2008 21:18:57 -0700, "Peter Duniho" <...@nnowslpianmk.com

On Wed, 02 Jul 2008 22:03:55 -0700, Abul Hasan Lakhani
<...@ecsonline.com.pk

If you're just using the project's Properties to store the string, then
you can access the string via the Properties.Settings.Default property for
your project.

If you're not storing the connection string that way, then you should be.
Otherwise you have to use the ConfigurationManager directly, which is a
pain (well, at least compared to using the Designer-provided Settings
class :) ).

Pete

On Thu, 3 Jul 2008 04:23:25 +0000 (UTC), Alex Meleta <...@gmail.com

Hi Abul,

You need some sort of System.Configuration.ConfigurationManager.ConnectionStrings["Containers.Properti es.Settings.Custom_JobConnectionString"]


Regards, Alex Meleta
mail...@gmail.com; blog:devkids.blogspot.com