Connection String not initialized

Discussion in 'ASP .Net' started by rodchar, Jan 24, 2008.

  1. rodchar

    rodchar Guest

    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
     
    rodchar, Jan 24, 2008
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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, Jan 24, 2008
    #2
    1. Advertising

  3. 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
     
    Milosz Skalecki [MCAD], Jan 24, 2008
    #3
  4. rodchar

    rodchar Guest

    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
     
    rodchar, Jan 24, 2008
    #4
  5. rodchar

    David Wier Guest

    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" <> wrote in message
    news:...
    > 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
     
    David Wier, Jan 24, 2008
    #5
  6. string dbConnection =
    ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;


    "rodchar" <> wrote in message
    news:...
    > 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
     
    Scott Roberts, Jan 24, 2008
    #6
  7. 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
     
    Milosz Skalecki [MCAD], Jan 25, 2008
    #7
  8. rodchar

    rodchar Guest

    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
     
    rodchar, Jan 31, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB
    Replies:
    3
    Views:
    54,694
    nada111
    Oct 4, 2007
  2. CJM
    Replies:
    2
    Views:
    4,506
  3. phil
    Replies:
    4
    Views:
    7,668
  4. Antoni Massó Mola
    Replies:
    1
    Views:
    414
    Michelle Hlaing
    Feb 24, 2005
  5. Chad
    Replies:
    4
    Views:
    131
    Bob Barrows [MVP]
    Feb 28, 2005
Loading...

Share This Page