ChrifRachid ChrifRachid - 3 months ago 21
C# Question

I need to attach .mdb database to C# desktop application

I included the database to the project files and build the solution, when I run the application in another machine I get that error

************** Exception Text **************


System.Configuration.ConfigurationErrorsException: Configuration
system failed to initialize --->
System.Configuration.ConfigurationErrorsException: Unrecognized
configuration section configuration. (C:\Documents and
Settings\windows\Desktop\IstanbulFood\POSApp\IstanbulFoodPOS\bin\Debug\IstanbulFoodPOS.exe.Config
line 8) 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) --- End of inner exception stack trace --- at
System.Configuration.ClientConfigurationSystem.EnsureInit(String
configKey) at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName) at
System.Configuration.ConfigurationManager.GetSection(String
sectionName) at
System.Configuration.ConfigurationManager.get_ConnectionStrings() at
IstanbulFoodPOS.dataAccess..ctor() in
D:\IstanbulFood\POSApp\IstanbulFoodPOS\dataAccess.cs:line 17 at
IstanbulFoodPOS.Login.EnterButton_Click(Object sender, EventArgs e) in
D:\IstanbulFood\POSApp\IstanbulFoodPOS\Login.cs:line 37 at
System.Windows.Forms.Control.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message&
m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at
System.Windows.Forms.Button.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************

mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
IstanbulFoodPOS
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/windows/Desktop/IstanbulFood/POSApp/IstanbulFoodPOS/bin/Debug/IstanbulFoodPOS.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Config file:

<?xml version="1.0"?>
<configuration>
<configSections> </configSections>
<connectionStrings>
<add name="IstanbulFoodDBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\IstanbulFood\POSApp\IstanbulFoodPOS\IstanbulFoodDB‌​.mdbb;Persist Security Info=True" providerName="System.Data.OleDb"/>
</connectionStrings>
<configuration>
<system.windows.forms jitDebugging="true"/>
</configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

Answer

It looks like you are having trouble with connection string. You can find examples in here.

Example connection string should be;

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb; Persist Security Info=False;
Comments