If you are using Sql Server express, you need to use a SqlConnection
, not a MySqlConnection
. That one is for use with MySQL, which is a different implementation of SQL than Microsoft SQL Server
Of course, Microsoft also offers the OleDbConnection
as kind of a "catch-all" (see more here: Difference between Sql Connection and OLEDB Connection). Still, if I know I'm going to stick with a particular SQL provider, then I generally use the specialized version.
Also, if you're ever interested, here is a small list of common SQL providers:
- Microsoft SQL Server - proprietary SQL provider developed and supported by Microsoft
- MySQL - Free, open source relational database system developed by Oracle. Very popular with web developers.
- PostgreSQL - another open-source RDBMS. Gaining popularity due to its flexibility and adherence to standards.
- SQLite - a small, SQL provider with an emphasis on portability. Unlike the others, it uses local database files rather than a remote server. This has made it pretty much the default choice when developing mobile applications that require local storage.