c#连接mysql 数据库 绝对能用
2013-06-04 10:36
337 查看
以下可以查询出在example数据库中person表中的所有信息
并且显示在datagrid中MySQLDriverCS 自己在网上随便找找就有一堆
并且显示在datagrid中MySQLDriverCS 自己在网上随便找找就有一堆
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MySQLDriverCS; namespace sqltest { public partial class Form1 : Form { MySQLDataAdapter mda; DataSet ds; public Form1() { InitializeComponent(); aa(); } public void aa() { MySQLConnection conn = null; try { string connstr = "Data Source=webexample;" + "Password=;User ID=root;Location=localhost"; conn = new MySQLConnection(connstr); conn.Open(); MySQLCommand commn = new MySQLCommand("set names gb2312", conn); commn.ExecuteNonQuery(); string sql = "select * from person "; mda = new MySQLDataAdapter(sql, conn); ds = new DataSet("MyData"); mda.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; } catch (Exception ex){ MessageBox.Show(ex.Message); } finally{ conn.Close(); } } } }
相关文章推荐
- c#连接mysql 数据库 绝对能用
- C#连接操作 MySQL 数据库实例(使用官方驱动)
- C#连接Access、SQL Server、Oracle、MySQL、DB2和SyBase六种不同数据库的程序源码和需要注意的点
- C# 连接 MySQL 并进行数据库操作(入门篇)
- C# 连接数据库MySql并执行查询命令
- C#连接4种类型数据库(Access、SQL Server、Oracle、MySQL)
- C# 操作 MySQL 数据库(连接,查询,插入)
- C#连接4种类型数据库(Access、SQL Server、Oracle、MySQL)
- C# 连接 MySql 数据库的方法
- C#连接操作 MySQL 数据库实例(使用官方驱动)
- C#连接4种类型数据库(Access、SQL Server、Oracle、MySQL)
- C# 使用MySQLDriverCS 连接MySQL 数据库
- VB6,C#连Sql server,Mysql,sqlite,access等数据库的连接字符串
- C# asp.net 连接Mysql 数据库
- C#连接4种类型数据库(Access、SQL Server、Oracle、MySQL)
- 【转】C# 连接 MySQL 并进行数据库操作(入门篇)
- C#连接4种类型数据库(Access、SQL Server、Oracle、MySQL)
- C#连接4种类型数据库(Access、SQL Server、Oracle、MySQL)
- C#连接数据库--VS中使用MYSQL connect Net 连接本地MYSQL
- C#连接各种数据库代码Access,Sql Server,Oracle,Mysql,IBM DB2,Sybase