PC Review


Reply
Thread Tools Rate Thread

Connection String not initialized

 
 
rodchar
Guest
Posts: n/a
 
      24th Jan 2008
hey all,

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

Can someone please tell me what I'm missing?

thanks,
rodchar
 
Reply With Quote
 
 
 
 
Scott Roberts
Guest
Posts: n/a
 
      24th Jan 2008
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["NorthwindConnectionString"].ConnectionString;



"rodchar" <(E-Mail Removed)> wrote in message
news:63B6AC3A-53FC-48D2-AAED-(E-Mail Removed)...
> hey all,
>
> SqlDataAdapter da = new SqlDataAdapter(@"Select * from Products",
> ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
> DataTable tbl = new DataTable();
> da.Fill(tbl);
>
> Can someone please tell me what I'm missing?
>
> thanks,
> rodchar


 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      24th Jan 2008
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(@"Select * from Products",
> ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
> DataTable tbl = new DataTable();
> da.Fill(tbl);
>
> Can someone please tell me what I'm missing?
>
> thanks,
> rodchar

 
Reply With Quote
 
rodchar
Guest
Posts: n/a
 
      24th Jan 2008
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(@"Select * from Products",
> > ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
> > DataTable tbl = new DataTable();
> > da.Fill(tbl);
> >
> > Can someone please tell me what I'm missing?
> >
> > thanks,
> > rodchar

 
Reply With Quote
 
David Wier
Guest
Posts: n/a
 
      24th Jan 2008
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" <(E-Mail Removed)> wrote in message
news:21E0204C-AE4D-4021-AC4F-(E-Mail Removed)...
> 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(@"Select * from Products",
>> > ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
>> > DataTable tbl = new DataTable();
>> > da.Fill(tbl);
>> >
>> > Can someone please tell me what I'm missing?
>> >
>> > thanks,
>> > rodchar



 
Reply With Quote
 
Scott Roberts
Guest
Posts: n/a
 
      24th Jan 2008
string dbConnection =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;


"rodchar" <(E-Mail Removed)> wrote in message
news:21E0204C-AE4D-4021-AC4F-(E-Mail Removed)...
> 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(@"Select * from Products",
>> > ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
>> > DataTable tbl = new DataTable();
>> > da.Fill(tbl);
>> >
>> > Can someone please tell me what I'm missing?
>> >
>> > thanks,
>> > rodchar


 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      25th Jan 2008
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(@"Select * from Products",
> > > ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
> > > DataTable tbl = new DataTable();
> > > da.Fill(tbl);
> > >
> > > Can someone please tell me what I'm missing?
> > >
> > > thanks,
> > > rodchar

 
Reply With Quote
 
rodchar
Guest
Posts: n/a
 
      31st Jan 2008
thanks again everyone for the feedback.
rod.

"rodchar" wrote:

> hey all,
>
> SqlDataAdapter da = new SqlDataAdapter(@"Select * from Products",
> ConfigurationSettings.AppSettings["NorthwindConnectionString"]);
> DataTable tbl = new DataTable();
> da.Fill(tbl);
>
> Can someone please tell me what I'm missing?
>
> thanks,
> rodchar

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection property has not been initialized sasi.vempalli@gmail.com Microsoft ADO .NET 1 19th Sep 2006 03:12 PM
Connection property has not been initialized sasi.vempalli@gmail.com Microsoft ADO .NET 0 19th Sep 2006 07:57 AM
Connection property has not been initialized sasi.vempalli@gmail.com Microsoft ADO .NET 0 19th Sep 2006 07:57 AM
Returning String initialized from Unmanaged Code skg Microsoft C# .NET 1 12th Aug 2005 10:07 AM
String Initialized to odd characters Elizabeth Graham Microsoft C# .NET 2 9th Jan 2004 04:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 AM.