sitemap connectionstrings

  • Thread starter Andy Sutorius via DotNetMonster.com
  • 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[] {';'});
 
W

Wouter van Vugt

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
 
A

Andy Sutorius via DotNetMonster.com

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?
 
W

Wouter van Vugt

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
 
A

Andy Sutorius via DotNetMonster.com

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top