Search code examples
c#mysqlwcf

Confusion on using Web Service using C# + MySql Database


Hello guys I have a confusing question! If I'm using WCF to create a web service, then I'm trying to connect my service to a database which is a mysql one!

After I have installed the .NET connector, still I can not refer to the database using

using MySql.Data.MySqlClient;

the client will be adding some sort of ID to the service and I want the WCF app Parse that value and feed it to the database!

I searched on StackOverflow as well and I found these two below to be an approach as well :

using System.Data.Odbc;
using System.Data.SqlClient;

Could this be connecting my service to the database ? Please if you think I have a misunderstanding in the way I want to load the drivers let me know!

THANKS


Solution

  • Based on your comment, it sounds like you added the MySql.Data.MySqlClient using statement to your project file(s), but you didn't actually add the DLL to your project.

    You can add the DLL to your project by looking in the solution explorer (usually the top-right window in Visual Studio), right-click on References, select Add Reference (not Add Service Reference) and then navigate to where you put the MySql drivers.

    Adding a using statement only works when the underlying assembly is included in the project's references.