Click here to Skip to main content
15,942,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all
Iam working with an windowsformapplication which consist of almost 45 forms and the database is MS Acess for the ease of Coding I had declared connectionstring as below in every Forms
public partial class LoginForm : Form
    private String connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\NauferTransactionDemoDB.accdb";

       public LoginForm()

But now project is almost over and I want to make this connection declared in appconfig so that I can change it easily if I want
Iam new to programming and is facing the problem with the same

i used

    <add name="connect">
         connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\NauferTransactionDemoDB.accdb";User Instance=True"

But when i try to call this in Forms like below
String cString = ConfigurationManager.ConnectionStrings["connect"]. connString;
I get Exception at connectionstring

Can any one help

[edit]"Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Updated 13-Feb-12 9:08am

1 solution

<add name="Name" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\NauferTransactionDemoDB.accdb";User Instance=True" />[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900