sitemap connectionstrings

  • Thread starter Thread starter Andy Sutorius via DotNetMonster.com
  • Start date Start date
A

Andy Sutorius via DotNetMonster.com

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[] {';'});
 
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
 
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?
 
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
 
Thank you for your help!
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
 
Back
Top