sean
sean

Reputation: 9258

Connection String Problem

I'm new to Visual Studio and MySQL. I'm creating a Login Page and connect it with MySQL. But whenever I add a connection string. I always got an error.

enter image description here

Can anybody tell me what's the problem in here?

Please.

This is my config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ODBCDriver" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=timekeeping;uid=root;pwd=admin;Option=3;"/>
</appSettings>
<connectionStrings>
<add name="ConnectionString" connectionString="Database=timekeeping;uid=root;pwd=admin;Option=3;" />
</connectionStrings>
</configuration>

Upvotes: 0

Views: 634

Answers (5)

Bibhu
Bibhu

Reputation: 4081

<configuration>
  <appSettings>
    <add key="ODBCDriver" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=timekeeping;uid=root;pwd=admin;Option=3;"/>
  </appSettings>
</configuration>

Upvotes: 1

Paul McLean
Paul McLean

Reputation: 3550

I'm not entirely familiar with MySQL connections, but your config file should look more like this

<configuration>
  <appSettings>
    <add key="ODBCDriver" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;"/>
  </appSettings>
  <connectionStrings>
    <add name="ConnectionString" connectionString="Database=timekeeping;uid=root;pwd=admin;Option=3;" />
  </connectionStrings>
</configuration>

Upvotes: 2

ChrisLively
ChrisLively

Reputation: 88044

This usually means there is a problem with your web.config file. Probably a tag out of place, not closed, or otherwise jacked.

http://msmvps.com/blogs/kevinmcneish/archive/2010/01/06/fixing-quot-configuration-system-failed-to-initalize-quot-exception.aspx

Upvotes: 1

SLaks
SLaks

Reputation: 887255

You probably have a syntax error in your App.config file.

Check the InnerException for details.

Upvotes: 1

BrokenGlass
BrokenGlass

Reputation: 160852

But whenever I add a connection string. I always got an error.

Your web.config or app.config configuration is not legal in its current form - this could be because of a typo, i.e an unclosed tag, otherwise malformed XML or a section that is unknown or nested in a section where it doesn't belong.

Upvotes: 0

Related Questions