C#连接MySQL数据库方法
C#连接MySQL数据库方法
1、用MySQLDriverCS连接MySQL数据库先下载和安装MySQLDriverCS,地址:
http://sourceforge.net/projects/mysqldrivercs
在安装文件夹下面找到MySQLDriver.dll,然后将MySQLDriver.dll添加引用到项目中
注:我下载的是版本是 MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySQLDriverCS;
namespace mysql
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
MySQLConnection conn = null;
conn = new MySQLConnection(new MySQLConnectionString("localhost", "inv", "root", "831025").AsString);
conn.Open();
MySQLCommand commn = new MySQLCommand("set names gb2312", conn);
commn.ExecuteNonQuery();
string sql = "select * from exchange ";
MySQLDataAdapter mda = new MySQLDataAdapter(sql, conn);
DataSet ds = new DataSet();
mda.Fill(ds, "table1");
相关文档:
首先建一个工程,准备好一个log4j的jar包和连接MySqL的驱动包。配置如下:
修改log4j.properties文件:
######## #此句为定义名为stdout的输出端是哪种类型,可以是
#org.apache.log4j.ConsoleAppender(控制台),
#org.apache.log4j.FileAppender(文件),
#org.apache.log4j.DailyRollingFileAppender(每天产生一 ......
1. 安装Cygwin
运行Cygwin的安装程序。从文见包的的列表中,在DEV里面,确定要选择
• Ruby
• gcc
• subversion
你需要使用gcc来建立Cygwin版本的MySQL.
2. 在windows上面安装MYSQL:
download MySQL 5.0 Windows Installer
3. & ......
版权声明
:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://bbayou.blogbus.com/logs/37045617.html
测试数据2.5G,共有数据9427567条。用的mysql的large服务器的配置。
load
一次需要大概10分钟左右。
建的表用的是MYISAM,调整了几个session的参数值
SET
SESSION
BULK_INSERT_BUFFER_S ......
1、MySQL是有一些环境变量可以设置,
可输入:show variables;可查看当前的环境变量设置;
2、这些变量当中有一部分与字符相关的设置,
可输入:show variables like ´character%´;查看;
3、其中character_set_results决定返回结果的编码,
windows下设为gb2312即可正常显示中文;
设置方法:set charac ......
Doing INTERSECT and MINUS in MySQL
By Carsten | October 3, 2005
Doing an INTERSECT
An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So
SELECT member_id, name from a
INTERSECT ......