sitemap connectionstrings

Discussion in 'ASP .Net' started by Andy Sutorius via DotNetMonster.com, Jan 10, 2006.

  1. I am creating a custom sitemap and when I run the site I get the following
    error and the debugger trips on line 28 of the code below. Can someone
    explain why I am getting this error and how to correct it?

    Parser Error Message: The entry 'LocalSqlServer' has already been added.

    Source Error:
    Line 13: </appSettings>
    Line 14: <connectionStrings>
    Line 15: <add
    Line 16: name="LocalSqlServer"
    Line 17: connectionString="server=(local); uid=sa; pwd=sterling;
    database=ca101web;"

    =========
    default.aspx.cs - line 28

    string[] connString = ConfigurationManager.ConnectionStrings["LocalSqlServer"]
    ..ConnectionString.Split(new Char[] {';'});

    --
    Message posted via http://www.dotnetmonster.com
     
    Andy Sutorius via DotNetMonster.com, Jan 10, 2006
    #1
    1. Advertising

  2. The LocalSqlServer connection string is configured in the
    c:\windows\Microsoft .NET\Framework\V2.0xxxx\Config\Web.config file.
    Yes, there is one there also :). Of course, you can't add the same
    connectionstring twice using the same name, as the name is used as the
    primary key.

    Wouter van Vugt
    Trainer - Info Support
    http://blogs.infosupport.com/wouterv
     
    Wouter van Vugt, Jan 10, 2006
    #2
    1. Advertising

  3. I am confused with the way the custom sitemap is supposed to work. Line 28
    comes from my Page Load and it is pulling the connection string from the web.
    config. I thought I needed the name of the connection string in line 28 in
    order to get the connection string information? I am then calling the
    Initialize method with the namevaluecollection from the connection string. Am
    I incorrect in my architecture?

    Wouter van Vugt wrote:
    >The LocalSqlServer connection string is configured in the
    >c:\windows\Microsoft .NET\Framework\V2.0xxxx\Config\Web.config file.
    >Yes, there is one there also :). Of course, you can't add the same
    >connectionstring twice using the same name, as the name is used as the
    >primary key.
    >
    >Wouter van Vugt
    >Trainer - Info Support
    >http://blogs.infosupport.com/wouterv


    --
    Message posted via http://www.dotnetmonster.com
     
    Andy Sutorius via DotNetMonster.com, Jan 10, 2006
    #3
  4. You should use a SiteMapDataSource, and set its Provider property. Then
    in the web.config you configure a custom SiteMapProvider, here you also
    set the connectionString. On line 28 of your code, you can use the name
    of the connectionstring, that isn't the problem. THe problem here is
    that the connectionstring you are requesting exists two times, one in
    the web.config for your root directory. One for the
    C:\windows\Microsoft.NET\..... folder.

    Grtz, Wouter
     
    Wouter van Vugt, Jan 11, 2006
    #4
  5. Thank you for your help!

    Wouter van Vugt wrote:
    >You should use a SiteMapDataSource, and set its Provider property. Then
    >in the web.config you configure a custom SiteMapProvider, here you also
    >set the connectionString. On line 28 of your code, you can use the name
    >of the connectionstring, that isn't the problem. THe problem here is
    >that the connectionstring you are requesting exists two times, one in
    >the web.config for your root directory. One for the
    >C:\windows\Microsoft.NET\..... folder.
    >
    >Grtz, Wouter


    --
    Message posted via DotNetMonster.com
    http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/200601/1
     
    Andy Sutorius via DotNetMonster.com, Jan 11, 2006
    #5
    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. Nathan Sokalski
    Replies:
    16
    Views:
    2,403
    Juan T. Llibre
    Jun 25, 2005
  2. Dave
    Replies:
    3
    Views:
    5,869
  3. Replies:
    8
    Views:
    563
    =?Utf-8?B?REo=?=
    Mar 28, 2006
  4. AmitKu
    Replies:
    1
    Views:
    812
    Cowboy \(Gregory A. Beamer\)
    Sep 27, 2006
  5. Learner
    Replies:
    5
    Views:
    278
    Dominick Baier [DevelopMentor]
    May 7, 2006
Loading...

Share This Page