I am unable to get the connection to work with using the app.config
file.
the connection works when I use 'in line' connection as below:
------------------------------------------------------------------
I have a declaration in the class
private OleDbConnection con;
Then code in a procedure as below:
1. This works:
con = new OleDbConnection
("Provider=Micr osoft.Jet.OLEDB .4.0;Password=; User ID=;Data
Source=C:\\Data \\C#Projects\\P roPay\\ProPay.m db;");
con.Open();
2. This does not work:
con = new OleDbConnection (ConfigurationS ettings.AppSett ings["DBConnectionSt ring"]);
con.Open();
The App.config file that is being called here is:
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<appSettings>
<!-- User application and configured property settings go
here.-->
<add key="DBConnecti onString"
value="Provider =Microsoft.Jet. OLEDB.4.0;Passw ord=;User ID=;Data
Source=C:\\Data \\C#Projects\\P roPay\\ProPay.m db;" />
</appSettings>
</configuration>
-----------------------------------------------------------
The error message provided (VisStudio 2003) is:
A first chance exception of type 'System.Invalid OperationExcept ion'
occurred in system.data.dll
Additional information: The ConnectionStrin g property has not been
initialized.
-------------
I have tried using the connection string generated through using oleDB
connection in the Dynamic properties of the OleDBConnection object
that I dragged onto a form. This did not work.
I have tried playing with the syntax a myriad of ways (ie single
backslashes) - no luck.
I used a connection string I generated from oleDBconnection object
dragged onto a form - no luck.
I have called the config file by MYApp.exe.confi g
If someone can point me in the right direction, I would be most
greatful. If there is a site with information relating to Data access
Using C# and MSAccess, this would be great too.
I have not had much joy using parametized queries using
oleDBCommand.Co mmandType.Store dProcedure. Can this be done or can one
only use "texttype?"
I have adapted info from
http://www.csharpfriends.com/Article...px?articleID=3
which relates to data Access and SQL databases but this uses stored
procedures which is where I am not winning.
Thanks in anticipation.
Grant