我的环境是:VS2005
1.去http://dev.mysql.com/downloads/connector/net/5.0.html上下载一个驱动程序,我下载的是mysql-connector-net-5.0.9.exe安装文件,下载安装完成后相关的MySql.Data.dll就会加载到C:/Program Files/MySQL/MySQL Connector Net 5.0.9/Binaries/.NET 2.0路径下。
2.在项目中选择添加引用,选择.NET,找到刚安装的MySql.Data确定
3.相关的简单测试如下
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
namespace MySQLTest
{
public class MySQLDBHelper
{
private static MySqlConnection conn;
private static MySqlCommand cmd;
public static MySqlCommand GetCommand(string sql, MySqlParameter[] param)
{
conn = new MySqlConnection("UserId=sa;Host=localhost;Database=school;Password=sa");