Click here to Skip to main content
13,551,917 members


QuestionApp.Config Pin
Aduu11-Nov-12 13:52
memberAduu11-Nov-12 13:52 
Hi, I am trying to access a MS Access database using Windows form. I added my connection string in App.congig file.
 <?xml version="1.0" encoding="utf-8" ?>

    <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;"/>

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.

I am not getting why I am getting this error. Can anyone please help me out in this. I am new in this functionality.

QuestionRe: App.Config Pin
Super Lloyd11-Nov-12 16:23
memberSuper Lloyd11-Nov-12 16:23 
AnswerRe: App.Config Pin
ryanb3112-Nov-12 5:30
memberryanb3112-Nov-12 5:30 
AnswerRe: App.Config Pin
Simon_Whale12-Nov-12 5:49
memberSimon_Whale12-Nov-12 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy |
Web01-2016 | 2.8.180515.1 | Last Updated 22 May 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid