本文实例讲述了C#连接mysql数据库的方法。分享给大家供大家参考。具体实现方法如下: using System;
using System.Configuration;
using MySql.Data.MySqlClient;
///
/// TestDatebase 的摘要说明
///
public class TestDatebase
{
public TestDatebase()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static void Main(String[] args)
{
MySqlConnection mysql = getMySqlCon();
//查询sql
String sqlSearch = "select * from student";
//插入sql
String sqlInsert = "insert into student values (12,'张三',25,'大专')";
//修改sql
String sqlUpdate = "update student set name='李四' where id= 3";
//删除sql
String sqlDel = "delete from student where id = 12";
//打印SQL语句
Console.WriteLine(sqlDel);