My program used to start even though Mysql is offline, it will open but give an indicator that the program is not connected to the database, which is what i want. I want it to start even if the database is offline and just give an indicator that its not connected I set a connection indicator like this:
public void connStatus()
{
MySqlConnection myConn = new MySqlConnection("SERVER = localhost; user id = root; password =; database = mpdb");
try
{
myConn.Open();
dbconsign.Visible = true;
dbnotconsign.Visible = false;
}
catch (Exception ex)
{
MetroMessageBox.Show(this, ex.Message , "NOTIFICATION", MessageBoxButtons.OK, MessageBoxIcon.Hand);
dbconsign.Visible = false;
dbnotconsign.Visible = true;
}
finally
{
if (myConn.State == ConnectionState.Open)
{
myConn.Close();
}
}
}
(I know that my code above is not the best one for checking server connections, but i just needed something to indicate if the database is online or offline, im new to programming and im not very good at it yet.)
now, after I added some dll's and went on with my little program, the program will only start if Mysql is Online. It won't start at all and will give messages like this:
Could not find schema information for the element 'setting'.
Could not find schema information for the element 'value'.
so i figured out something is wrong at the App.Config, and the problem is I only have little knowledge on XML and i don't understand whats going on with the one on my project. Can someone please tell me why is this happening? and how do i fix it? Any suggestions and corrections are highly appreciated.
this is the App.config of my project:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="cpsfmV2._0.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<cpsfmV2._0.Properties.Settings>
<setting name="CurrentDate" serializeAs="String">
<value />
</setting>
</cpsfmV2._0.Properties.Settings>
</userSettings>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.12.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.9.12.0" newVersion="6.9.12.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>