使用MySQLDriverCS
在解决方案资源管理器中,添加引用,将MySQLDriverCS.dll添加进去就可以.
下面是使用MySQLDriverCS的代码示例:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MySQLDriverCS;
namespace WebApplication1
{
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("aspnet连接Mysql数据库");
string constr = "Data Source=hehe;Password=root;User ID=root;Location=localhost"; */Data Source=使用的数据库的名字 特别注意空格/*
MySQLConnection conn = new MySQLConnection(constr);
conn.Open();
string query = "create table heihei(haha char(20));"; */注意“;”别丢了!!!/*
MySQLCommand cmd = new MySQLCommand(query, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
}
}
在解决方案资源管理器中,添加引用,将MySQLDriverCS.dll添加进去就可以.
下面是使用MySQLDriverCS的代码示例:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MySQLDriverCS;
namespace WebApplication1
{
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("aspnet连接Mysql数据库");
string constr = "Data Source=hehe;Password=root;User ID=root;Location=localhost"; */Data Source=使用的数据库的名字 特别注意空格/*
MySQLConnection conn = new MySQLConnection(constr);
conn.Open();
string query = "create table heihei(haha char(20));"; */注意“;”别丢了!!!/*
MySQLCommand cmd = new MySQLCommand(query, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
}
}