Connection String not initialized

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

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
 
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;
 
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
 
You are right that it's in the connectionStrings section, how do you get to
that?

Milosz Skalecki said:
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 said:
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
 
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 said:
You are right that it's in the connectionStrings section, how do you get
to
that?

Milosz Skalecki said:
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 said:
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
 
string dbConnection =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;


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

Milosz Skalecki said:
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 said:
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
 
Howdy,

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

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

HTH
--
Milosz


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

Milosz Skalecki said:
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 said:
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
 
Back
Top