Here is my app.config file :
providerName="System.Data.SqlClient" />
Question 1 ) How do I pull this out? I want dbConnection connectionString. This ought to be simple, but the document is driving me nuts.
Question 2 ) You will note that part of the path for the connectionString contains "|DataDirectory|" (obviously a variable, maybe and ENV variable), where is this stored and how is it expanded?
TIA Ken
ETA: edited in Firefox.
Master BillaPosted Sep 1, 2009, 11:04 AM
You can read the connection string in easier way
string conectionstring = System.ConfigurationManager.ConnectionStrings["dbConnection"].ToString();
SystemDirectory is main path of the database file.
thank you
Kirtan PatelPosted Sep 1, 2009, 8:54 AM
by looking at your problem it looks like
you forgot to Import Namespace
using System.Configuration;
then you can access Connection String using Following Code
Label1.Text = ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString.ToString();
Posted Sep 1, 2009, 8:41 AM
Ken BarrettPosted Jul 31, 2009, 4:47 PM
The documentation seems to suggest :
String connString = ConfigurationManager.ConnectionStrings["dbConnection"].ToString();
However I'm stumbling over ConfigurationManager, as this does not exist in the current context, and I don't know where to find it.
BY THE WAY.. my formatting issues seem to be linked to my choice of browser.. I was using Opera, this entry was created on Firefox.