Why is my website trying to open a connection to SQL server when it has MySQL? RRS feed

  • Question

  • User-696641838 posted

    I have created a MySQL database for the local host and confirmed that the connection tests as good for my website with the .NET Framework Data Provider for MySQL in Visual Studio.  But, the first time that my website attempts to access a table in the database, a server error occurs, which says: Could not open a connection to SQL Server.  Why is my website looking for an SQL server when it is connected to a MySQL database?  Should I be including something other than “using System.Data.SqlClient;” or adding a reference? 

     I have set the connection string in the web.config file as: connectionString="Data Source=.NET Framework Data Provider for MySQL;Initial Catalog=vfwd1_encdb;User id=root;Password=123;Trusted_Connection=True" />  Is this proper?  What am I missing?  Please help.


    Saturday, September 5, 2015 6:26 PM


All replies

  • User2024324573 posted

    Hi Maurice,

    You need to reference MySql.Data in your project and use MySql.Data.MySqlClient in you code.

    Please refer to:


    Hope this will help.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 5, 2015 7:44 PM
  • User-696641838 posted

    Wow!  I can't wait to check this out.  I don't know anything about those references or MVC, but I will look into this.  Thanks.


    Saturday, September 5, 2015 8:21 PM
  • User-696641838 posted

    Hi Mostafa,

    Thank you for the link that you provided.  Unfortunately, I did not understand much of it since I only have Visual Studio 2008 and I know nothing about MVC other than creating a database and tables with MySQL Workbench.  But I did notice the inclusion of the using statement for the MySql.Data.MySqlClient namespace, which I added to my code segments.  I also noticed the use of MySqlConnection and MySqlCommand instead of SqlConnection and SqlCommand as I previously used with an SQL database.  So, I assume that I will need to make these changes in my code.  Is there anything else that I need to do?


    Saturday, September 5, 2015 9:09 PM
  • User-696641838 posted

    I added a reference to MySql.Data and included a using statement for the MySql.Data.MySqlClient namespace as well as changed all references of SqlConnection and SqlCommand to that of MySqlConnection and MySqlCommand.  This worked fine wherever this type of database access occurred.  But server errors occurred wherever I used the DataClassesDataContext method to submit changes to a table such as:


    DataClassesDataContext db = new DataClassesDataContext();

    Profile profile = new Profile();

    profile.Names = Names;




    How can I make these forms of data table access work with the MySQL database?



    Sunday, September 6, 2015 5:45 AM