Using MySQL with .NET

Introduction

Ever wanted to combine the power and ease of the .NET platform with a free database like MySQL? Well thanks to ODBC database functions in ADO.NET it's really easy. All you need is the latest drivers for ADO.NET and MySQL installed. For this tutorial we will use C# to build a simple application for reading a table built in MySQL. This assumes at least basic knowledge of C# and .NET.

Creating the Database

To start the project, we will need to create a mysql database to work with. Create a new database called mysqlsample and create a new table like this:

mysql> create database mysqlsample;

mysql> use mysqlsample;

mysql> create table tutorials (id int not null auto_increment, title varchar(80) not null, link varchar(255) not null, primary key(id));

mysql> insert into tutorials values (1, ‘DOT.NET For Dummies', ‘http://www.dotnetfordummies.com');

mysql> insert into tutorials values (2, ‘XML For Idiots', ‘http://www.xmlforidiots.com');

mysql> insert into tutorials values (3, ‘Windows For Wimps', ‘http://www.windowsforwimps.com');

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth