K
K Viltersten
I've changed the declaration of the
connection string in my application from
String conStr = "the string";
to an external one, behaving as a property
of my class (supposedly, a nicer approach,
i've been told).
private string _ConStr;
public string ConStr {
get {
if (String.IsNullOrEmpty(_ConStr))
_ConStr = GetConnectionString();
return _ConStr; }
set { } }
After that, i've designed the method for
obtaining the connection string as follows.
private string GetConnectionString() {
ConnectionStringsSection css
= ConfigurationManager.GetSection
("connectionStrings") as
ConnectionStringsSection;
return
css.ConnectionStrings["MyConStr"]
.ConnectionString; }
In the web.config file i have these lines.
<connectionStrings>
<add name="MyConStr"
connectionString="the string" />
</connectionStrings>
Now, my question is twofold. First of all,
i'd like to know where i should put in
the web.config file when i install my
software on the computer of the intended
user. Secondly, i wonder if i've missed
something important in my approach.
connection string in my application from
String conStr = "the string";
to an external one, behaving as a property
of my class (supposedly, a nicer approach,
i've been told).
private string _ConStr;
public string ConStr {
get {
if (String.IsNullOrEmpty(_ConStr))
_ConStr = GetConnectionString();
return _ConStr; }
set { } }
After that, i've designed the method for
obtaining the connection string as follows.
private string GetConnectionString() {
ConnectionStringsSection css
= ConfigurationManager.GetSection
("connectionStrings") as
ConnectionStringsSection;
return
css.ConnectionStrings["MyConStr"]
.ConnectionString; }
In the web.config file i have these lines.
<connectionStrings>
<add name="MyConStr"
connectionString="the string" />
</connectionStrings>
Now, my question is twofold. First of all,
i'd like to know where i should put in
the web.config file when i install my
software on the computer of the intended
user. Secondly, i wonder if i've missed
something important in my approach.