tags:

views:

612

answers:

4

I need to access a mysql database from c# but I would prefer to go directly there and not use odbc.

I have to create a demo and I am using xampp on a usb drive and my data stuffer is written in c#. So to keep the usb drive isolated from the computer that the demo runs on. I am moving away from odbc because of setup reasons.

+5  A: 

http://dev.mysql.com/downloads/connector/net/5.2.html

Last time I tried it it worked fine but if you need to connect to, for example, MySQL and SQL Server you'll need to duplicate the code once using SqlConnection and the other using MysqlConnection.

Vinko Vrsalovic
+2  A: 

You'll probably want to use the MySQL .Net connector

Kibbee
+1  A: 

Depending on your needs, you could also look at an ORM like SubSonic. It works with MySQL and will give you both database independence and ease of development.

Rob Prouse
+2  A: 

In the vein of Object Relational Mappers, you can use NHibernate with MyGeneration Code Generator to generate both the mappings and classes you'd need to have a Data Access layer. There are a myriad of examples available.

FWIW, Unless you have specific parts where speed is absolutely critical, an ORM like NHibernate takes care of the CRUD stuff for you, and all you have to worry about is optimizing the parts where you really need speed.

This helps your issue because you have the ease of DAL creation (MyGeneration can look at your database and generate everything you need), and you can worry about the Business Logic of your application. It takes your problem and removes the need for you to even worry about whether ODBC is being used.

George Stocker