I've moved my Database connection string into my app.config - however its causing a null exception error when i use it
App.Config
vb Code:
<connectionStrings> <add name="MyData" connectionString="Provider=Microsoft.Jet.Oledb.4.0;Data Source=MyData.mdb;Jet OLEDB:Database Password=123456789" providerName="System.Data.OleDb" /> </connectionStrings>
I am trying to connect to it using
vb Code:
Dim con6 As New OleDbConnection(ConfigurationManager.ConnectionStrings("MyData").ConnectionString)
But that crashes with a null exception error in the JIT debugger "object reference not set to an instance of an object"
However if i move the connection string to a global module class called "Strings"
vb Code:
'db connection Friend DBConnectstrings = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=MyData.mdb;Jet OLEDB:Database Password=123456789"
and call it using
vb Code:
Dim con6 As New OleDbConnection(Strings.DBConnectstrings)
It works fine
I've added the reference systems.configuration to my application
And i've added 'imports system.configuration'
Any idea what i'm doing wrong?![]()




Reply With Quote