不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
.NET连接MySQL数据库示例
编辑:dnawo 日期:2014-05-30
一、安装MySQL 5.6
说明:选择安装功能时注意选择MySQL Connectors/NET。
二、创建测试数据
用MySQL Workbench连接数据库服务器,创建测试表添加数据:
三、.NET连接MySQL数据库示例
1).添加引用MySql.Data.dll,默认位置在C:\Program Files\MySQL\Connector NET 6.8.3\Assemblies;
2)..NET连接MySQL数据库:
相关下载
[1].MySQL:http://www.mysql.com/downloads/
[2].MySQL Connectors:http://www.mysql.com/products/connector/
说明:选择安装功能时注意选择MySQL Connectors/NET。
二、创建测试数据
用MySQL Workbench连接数据库服务器,创建测试表添加数据:
三、.NET连接MySQL数据库示例
1).添加引用MySql.Data.dll,默认位置在C:\Program Files\MySQL\Connector NET 6.8.3\Assemblies;
2)..NET连接MySQL数据库:
复制内容到剪贴板 程序代码
using System;
using System.Data;
using MySql.Data.MySqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;pwd=root123;database=test"))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand("select * from Person", conn))
{
MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
Console.WriteLine("{0},{1},{2}", reader["Id"], reader["Name"], reader["Age"]);
}
}
conn.Close();
}
Console.ReadKey();
}
}
}
using System.Data;
using MySql.Data.MySqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;pwd=root123;database=test"))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand("select * from Person", conn))
{
MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
Console.WriteLine("{0},{1},{2}", reader["Id"], reader["Name"], reader["Age"]);
}
}
conn.Close();
}
Console.ReadKey();
}
}
}
相关下载
[1].MySQL:http://www.mysql.com/downloads/
[2].MySQL Connectors:http://www.mysql.com/products/connector/
上一篇: 招商银行定期存款部分提前支取咨询
下一篇: Entity Framework连接MySQL数据库示例
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
下一篇: Entity Framework连接MySQL数据库示例
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
评论: 0 | 引用: 0 | 查看次数: 2344
发表评论
请登录后再发表评论!