Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / January 2008

Tip: Looking for answers? Try searching our database.

Connection String not initialized

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 24 Jan 2008 20:33 GMT
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
Scott Roberts - 24 Jan 2008 20:49 GMT
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;

> hey all,
>
[quoted text clipped - 7 lines]
> thanks,
> rodchar
Milosz Skalecki [MCAD] - 24 Jan 2008 21:10 GMT
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
Signature

Milosz

> hey all,
>
[quoted text clipped - 7 lines]
> thanks,
> rodchar
rodchar - 24 Jan 2008 21:54 GMT
You are right that it's in the connectionStrings section, how do you get to
that?

> Hi there Rod,
>
[quoted text clipped - 18 lines]
> > thanks,
> > rodchar
David Wier - 24 Jan 2008 21:57 GMT
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

> You are right that it's in the connectionStrings section, how do you get
> to
[quoted text clipped - 26 lines]
>> > thanks,
>> > rodchar
Scott Roberts - 24 Jan 2008 22:19 GMT
string dbConnection =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;

> You are right that it's in the connectionStrings section, how do you get
> to
[quoted text clipped - 26 lines]
>> > thanks,
>> > rodchar
Milosz Skalecki [MCAD] - 25 Jan 2008 00:16 GMT
Howdy,

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

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

HTH
Signature

Milosz

> You are right that it's in the connectionStrings section, how do you get to
> that?
[quoted text clipped - 21 lines]
> > > thanks,
> > > rodchar
rodchar - 31 Jan 2008 13:50 GMT
thanks again everyone for the feedback.
rod.

> hey all,
>
[quoted text clipped - 7 lines]
> thanks,
> rodchar

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.