re:
ConfigurationManager.ConnectionStrings["Test.My.Settings.conni"]
HaVoK could also use :
<%$ ConnectionStrings:Test.My.Settings.conni%>
HaVoK probably shouldn't use the "My.Settings" name.
It's confusing, since there's a programming feature named
"My.Settings", which can't be used in a web application.
I'd use something like :
ConnString="<%$ ConnectionStrings:Conn %>"
in the SqlConnection.
or, importing System.Web.Configuration :
string conn = WebConfigurationManager.ConnectionStrings["conn"].ConnectionString;
You could even use :
String conn = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
or
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrin gs["conn"].ToString());
....as long as you import System.Configuration.
This last one is functionally the same as your example.
Juan T. Llibre, asp.net MVP
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
===================================
"Milosz Skalecki" <mi*****@REMOVEITwp.plwrote in message
news:5E**********************************@microsof t.com...
ConfigurationManager.ConnectionStrings["Test.My.Settings.conni"]
--
Milosz Skalecki
MCP, MCAD
"HaVoK" wrote:
>Hello,
i am developing a website and want to use the connectionstring of my
web.config in other sites.
i have a connectionstring in my web.config like this:
<configuration>
<appSettings/>
<connectionStrings>
<add name="Test.My.Settings.conni" connectionString="*******"
providerName="System.Data.SqlClient" />
</connectionStrings>
i have found a lot of examples for windows applications like this.
connection = My.Settings.conni
but the parameter My.Settings is not available in my Website-Project.
only my.user, e.g.
How can i use this connection in my Website? is there any way?
Best regards
Benjamin