Connection String not initialized

hey all,

SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
DataTable tbl = new DataTable();
da.Fill(tbl);

Can someone please tell me what I'm missing?

thanks,
rodchar
rodchar [ Do, 24 Januar 2008 21:33 ] [ ID #1915222 ]

Re: Connection String not initialized

Connection strings are *typically* stored in the <ConnectionStrings> section
of web.config, not <AppSettings>. If that's the case, try this:

string dbConnection =
ConfigurationManager.ConnectionStrings["NorthwindConnectionS tring"].ConnectionString;



"rodchar" <rodchar [at] discussions.microsoft.com> wrote in message
news:63B6AC3A-53FC-48D2-AAED-1BCE67565338 [at] microsoft.com...
> hey all,
>
> SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
> ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
> DataTable tbl = new DataTable();
> da.Fill(tbl);
>
> Can someone please tell me what I'm missing?
>
> thanks,
> rodchar
Scott Roberts [ Do, 24 Januar 2008 21:49 ] [ ID #1915223 ]

RE: Connection String not initialized

Hi there Rod,

Don't get me wrong but I would suggest you to start using every's
programmer's best friend - debugger. In this particular case seems connection
string is not defined in app settings, maybe there's a typo in the web.config
or it's defined but under connectionStrings section. Debugger will save you
time as you can pick up bugs much quicker than asking questions and waiting
for the reply.

Have a good night
--
Milosz


"rodchar" wrote:

> hey all,
>
> SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
> ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
> DataTable tbl = new DataTable();
> da.Fill(tbl);
>
> Can someone please tell me what I'm missing?
>
> thanks,
> rodchar
mily242 [ Do, 24 Januar 2008 22:10 ] [ ID #1915227 ]

RE: Connection String not initialized

You are right that it's in the connectionStrings section, how do you get to
that?

"Milosz Skalecki [MCAD]" wrote:

> Hi there Rod,
>
> Don't get me wrong but I would suggest you to start using every's
> programmer's best friend - debugger. In this particular case seems connection
> string is not defined in app settings, maybe there's a typo in the web.config
> or it's defined but under connectionStrings section. Debugger will save you
> time as you can pick up bugs much quicker than asking questions and waiting
> for the reply.
>
> Have a good night
> --
> Milosz
>
>
> "rodchar" wrote:
>
> > hey all,
> >
> > SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
> > ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
> > DataTable tbl = new DataTable();
> > da.Fill(tbl);
> >
> > Can someone please tell me what I'm missing?
> >
> > thanks,
> > rodchar
rodchar [ Do, 24 Januar 2008 22:54 ] [ ID #1915234 ]

Re: Connection String not initialized

What exactly do you mean by 'how do you get to that?"
The web.config file is a file, like any other in the root directory of the
website, that you can open and edit.

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"rodchar" <rodchar [at] discussions.microsoft.com> wrote in message
news:21E0204C-AE4D-4021-AC4F-E82324556A30 [at] microsoft.com...
> You are right that it's in the connectionStrings section, how do you get
> to
> that?
>
> "Milosz Skalecki [MCAD]" wrote:
>
>> Hi there Rod,
>>
>> Don't get me wrong but I would suggest you to start using every's
>> programmer's best friend - debugger. In this particular case seems
>> connection
>> string is not defined in app settings, maybe there's a typo in the
>> web.config
>> or it's defined but under connectionStrings section. Debugger will save
>> you
>> time as you can pick up bugs much quicker than asking questions and
>> waiting
>> for the reply.
>>
>> Have a good night
>> --
>> Milosz
>>
>>
>> "rodchar" wrote:
>>
>> > hey all,
>> >
>> > SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
>> > ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
>> > DataTable tbl = new DataTable();
>> > da.Fill(tbl);
>> >
>> > Can someone please tell me what I'm missing?
>> >
>> > thanks,
>> > rodchar
David Wier [ Do, 24 Januar 2008 22:57 ] [ ID #1915236 ]

Re: Connection String not initialized

string dbConnection =
ConfigurationManager.ConnectionStrings["NorthwindConnectionS tring"].ConnectionString;


"rodchar" <rodchar [at] discussions.microsoft.com> wrote in message
news:21E0204C-AE4D-4021-AC4F-E82324556A30 [at] microsoft.com...
> You are right that it's in the connectionStrings section, how do you get
> to
> that?
>
> "Milosz Skalecki [MCAD]" wrote:
>
>> Hi there Rod,
>>
>> Don't get me wrong but I would suggest you to start using every's
>> programmer's best friend - debugger. In this particular case seems
>> connection
>> string is not defined in app settings, maybe there's a typo in the
>> web.config
>> or it's defined but under connectionStrings section. Debugger will save
>> you
>> time as you can pick up bugs much quicker than asking questions and
>> waiting
>> for the reply.
>>
>> Have a good night
>> --
>> Milosz
>>
>>
>> "rodchar" wrote:
>>
>> > hey all,
>> >
>> > SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
>> > ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
>> > DataTable tbl = new DataTable();
>> > da.Fill(tbl);
>> >
>> > Can someone please tell me what I'm missing?
>> >
>> > thanks,
>> > rodchar
Scott Roberts [ Do, 24 Januar 2008 23:19 ] [ ID #1915237 ]

RE: Connection String not initialized

Howdy,

c#
System.Configuration.ConfigurationManager.ConnectionStrings[ "ConnectionStringName"].ConnectionString

vb.net
System.Configuration.ConfigurationManager.ConnectionStrings( "ConnectionStringName").ConnectionString

HTH
--
Milosz


"rodchar" wrote:

> You are right that it's in the connectionStrings section, how do you get to
> that?
>
> "Milosz Skalecki [MCAD]" wrote:
>
> > Hi there Rod,
> >
> > Don't get me wrong but I would suggest you to start using every's
> > programmer's best friend - debugger. In this particular case seems connection
> > string is not defined in app settings, maybe there's a typo in the web.config
> > or it's defined but under connectionStrings section. Debugger will save you
> > time as you can pick up bugs much quicker than asking questions and waiting
> > for the reply.
> >
> > Have a good night
> > --
> > Milosz
> >
> >
> > "rodchar" wrote:
> >
> > > hey all,
> > >
> > > SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
> > > ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
> > > DataTable tbl = new DataTable();
> > > da.Fill(tbl);
> > >
> > > Can someone please tell me what I'm missing?
> > >
> > > thanks,
> > > rodchar
mily242 [ Fr, 25 Januar 2008 01:16 ] [ ID #1915987 ]

RE: Connection String not initialized

thanks again everyone for the feedback.
rod.

"rodchar" wrote:

> hey all,
>
> SqlDataAdapter da = new SqlDataAdapter( [at] "Select * from Products",
> ConfigurationSettings.AppSettings["NorthwindConnectionString "]);
> DataTable tbl = new DataTable();
> da.Fill(tbl);
>
> Can someone please tell me what I'm missing?
>
> thanks,
> rodchar
rodchar [ Do, 31 Januar 2008 14:50 ] [ ID #1920719 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » Connection String not initialized

Vorheriges Thema: Calling Webservice from ASP using httpGet now breaks calls from .Net
Nächstes Thema: Manipulate style/classes after all controls are being created - how?