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");
相关文档:
在Zend FrameWork中调用mysql的存储过程方法如下:
$db = Zend_Db::factory($sql_DbType,$sql_Config);
$connection=$db->getConnection();
Zend_Registry::set("db",$db);
Zend_Registry::set("connect",$connection);
调用存储过程如下代码所示:
$this->_db = Zend_Registry::get('db');
$connection=Zend_ ......
/// <summary>
/// 根据指定参数返回BitMap对象
/// 引用如下:
/// using System.Drawing;
/// 调用例子如下:
......
今天写一个商品的修改功能时遇到的问题
商品中重量 weight 的数据库(SQL Server2005)类型定义为 float
在mappings 中转换为c#类型的一句为
<result property="Goods_Weight" column="Goods_Weight" type="float" dbType="float"/>
按理说这个 float 是一样的,转换完全不会出现问题,
实际程序运行时,系统报错
......
版权声明
:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://bbayou.blogbus.com/logs/37045617.html
测试数据2.5G,共有数据9427567条。用的mysql的large服务器的配置。
load
一次需要大概10分钟左右。
建的表用的是MYISAM,调整了几个session的参数值
SET
SESSION
BULK_INSERT_BUFFER_S ......
MySQL日期字段分Date和Time两种,oracle日期字段只有Date,包含年月日时分秒信息,用当前数据库的系统时间为sysdate,精确到秒,或者用字符串转换日期型函数:
To_date('2001-08-01','YYYY-MM-DD'); 年-月-日
24小时:分钟:秒的格式 'YYYY-MM-DD HH24:MI:SS'  ......