Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27400

VS 2013 [RESOLVED] Adding connectionstring to configurationManager throws exception

$
0
0
I'm tinkering with a side project (a time card system), and one of the things I'd like to do with it is have different databases should the user want to keep things separated.
To keep it light and simple I'm using SQLite. I'm able to create a database file just fine. Now what I'm trying to do is add that file to the connectionstrings section of the config file programatically.

this is the line I'm using:
Code:

System.Configuration.ConfigurationManager.ConnectionStrings.Add(New System.Configuration.ConnectionStringSettings(databaseName, dbPath))
And it's throwing an error:
Quote:

Originally Posted by Copied from exception window
System.Configuration.ConfigurationErrorsException occurred
BareMessage=Configuration system failed to initialize
HResult=-2146232062
Line=0
Message=Configuration system failed to initialize
Source=System.Configuration
StackTrace:
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.G etSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at TimeCard.DatabaseFactory.createNewDatabase(String databaseName) in E:\Source\Mine\TimeCard\TimeCard\DatabaseFactory.vb:line 19
InnerException: System.Configuration.ConfigurationErrorsException
BareMessage=Unrecognized configuration section connectionstrings.
Filename=E:\Source\Mine\TimeCard\TimeCard\bin\Debug\TimeCard.vshost.exe.Config
HResult=-2146232062
Line=6
Message=Unrecognized configuration section connectionstrings. (E:\Source\Mine\TimeCard\TimeCard\bin\Debug\TimeCard.vshost.exe.Config line 6)
Source=System.Configuration
StackTrace:
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
InnerException:

Clicking the "get general help for this exception" takes me to this:
https://msdn.microsoft.com/query/dev...ng-VB)&rd=true
Quote:

The exception that is thrown when a configuration system error has occurred.
Really? No shlecking fit Sherlock!

Unrecognized configuration section connectionstrings.
???
Copied right from the config file:
Code:

  <connectionstrings>
    <add name="DBConnectionString" connectionString="C:\" />
  </connectionstrings>

So there is a connectionstrings node... so... what the heck am I missing here?

Meanwhile I'm going to rummage through google see if I can find something.

-tg

Viewing all articles
Browse latest Browse all 27400

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>