473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

my.settings website

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

Oct 20 '06 #1
4 2040
My.Settings doesn't apply to Web Applications.

See a chart which shows the applicable project types for each My object:
http://msdn2.microsoft.com/en-us/library/ms172698.aspx

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/
===================================

"HaVoK" <ha**********@googlemail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
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


Oct 20 '06 #2
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

Oct 20 '06 #3
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



Oct 20 '06 #4
thanks a lot for the fast and good answers.
that was exaxtly what i am looking for.

another question: if i want to set the server dynamicly for example
like tihs.../main.aspx?server=bgu03
is there any way to generate the serverstring automaticly by looking at
the url extension or anything else?

i want to have the possibility for the users to select if they want to
go to a test-server or the production-server.
Thanks for your help.

Best regards.
Benjamin

Oct 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Maellic | last post by:
Hi, I'm having real trouble locating configuration settings on an existing website. Details follow: I've recently taken over a website developed with ASP.NET. Unfortunately the original...
5
by: NoNickname | last post by:
Basically, how do I know that the release versions of all components are being published? The Build | Configuration Manager is confusing me a little in VS2005. I have three projects in my...
1
by: Philipp Lenz | last post by:
I'm completely new to ASP.Net 2.0 and I'm baffled about what to do to get this to work. FYI, I'm not new at this, I've used asp.net 1.1 for allmost 4 years now. I'm running a development...
0
by: Jeff | last post by:
ASP.NET 2.0 I created 3 users in my website. After creating these 3 users I wanted to make the password less restrict so I added the settings below to my web.config. (that means the 3 users...
6
by: Eric | last post by:
Hi Everyone, I have an ASP 1.1 website being hosted in a virtual directory that is a child node of an ASP 2.0 website. So I have: http://mainapp (which is a 2.0 site) And: ...
5
by: Ron | last post by:
Hi all, I am new at .net 2.0 deployment so can any one recommend me a good way or article to follow? What I want to do is (1)to deploy the website on the server2003 with IIS6 (2)we have...
1
by: seriouswebsupport | last post by:
Sorry - hopefully have this in the right group? ------- Hi, We have a client who keeps running into problems trying to access number of javascript applications through out their website....
2
by: Jeff | last post by:
hey ..net 3.5 I've published my website to another machine I have here, win2k3 machine. When I try to navigate to the website in IE I get an error saying "Unrecognized attribute 'type'" and...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.