I am beginning the trek of incorporating an SQL database into an application that I wrote which is operational. As part of that trek I am trying to read the connection string from the app.config file in order to connect to the database. I have tried a number of different constructs which either produce "no constructor" errors or the pair that I have in the following example. With regards to the code below what "object" are they referring to. Any help would be greatly appreciated.
'form 1
Dim SQLCnn As SqlConnection
SQLCnn = New SqlConnection(ConfigurationManager.ConnectionStrings _
("WindowsApplication1.My.MySettings.invgenConnectionString").ConnectionString)
'form 2
Dim SQLCnn As New SqlConnection(ConfigurationManager.ConnectionStrings _
("WindowsApplication1.My.MySettings.invgenConnectionString").ConnectionString)
The above two constructs produce the following error
System.NullReferenceException: Object reference not set to an instance of an object.
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
The "WindowsApplicatoin1" verbiage is the "name" specification that came from the app.config file which is the parameter data for the ConnectionStrings() property.
Respectfully,
'form 1
Dim SQLCnn As SqlConnection
SQLCnn = New SqlConnection(ConfigurationManager.ConnectionStrings _
("WindowsApplication1.My.MySettings.invgenConnectionString").ConnectionString)
'form 2
Dim SQLCnn As New SqlConnection(ConfigurationManager.ConnectionStrings _
("WindowsApplication1.My.MySettings.invgenConnectionString").ConnectionString)
The above two constructs produce the following error
System.NullReferenceException: Object reference not set to an instance of an object.
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
The "WindowsApplicatoin1" verbiage is the "name" specification that came from the app.config file which is the parameter data for the ConnectionStrings() property.
Respectfully,