|
Hi, I am trying to access a MS Access database using Windows form. I added my connection string in App.congig file.
="1.0"="utf-8"
<configuration>
<connectionStrings>
<clear/>
<add name="Constr" providerName="System.Data.OleDb"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\XXXX\\Documents\\YYYYY.accdb; Persist Security Info=False;"/>
</connectionStrings>
</configuration>
Code I added in my code to read this is
string connectionstring = ConfigurationManager.ConnectionStrings["Constr"].ConnectionString;
but I am getting following error on this line.
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=LoadTrackingTool.
I am not getting why I am getting this error. Can anyone please help me out in this. I am new in this functionality.
Thnx,
Aduu
|
|
|
|
|
Stack Traces do help!
put it there please!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
modified 12-Nov-12 1:17am.
|
|
|
|
|
You'll have to step through the code and find what line of code causes the error. At a quick glance I don't think it is failing on getting the connection string.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
have you tried
string connectionString = ConfigurationManager.ConnectionStrings["Constr"].ToString();
Simon
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|