ADO.Net连接Mysql
首先下载一个mysql.data.dll拷贝到bin下面并引用一下
using MySql.Data.MySqlClient;
class Program
{
static void Main(string[] args)
{
string connStr = ConfigurationManager.ConnectionStrings["sql"].ConnectionString;
using (MySqlConnection conn = new MySqlConnection(connStr))
{
string sql = "select * from sys_user ";
conn.Open();
using (MySqlCommand cmd = new MySqlCommand(sql, conn))
{
using (MySqlDataReader dataReader = cmd.ExecuteReader())
{
while (dataReader.Read())
{
string obj = (string)dataReader[1];
Console.WriteLine(obj);
}
} }
} }
}
mysql的mysql库中user表的Host字段设置为%,配置文件连接字符串为:
<connectionStrings>
<add name="sql" connectionString="server=127.0.0.1;Database=crm_db;UID=root;PWD=1" />
</connectionStrings>
ADO.Net连接Mysql的更多相关文章
- VS2013使用EF6通过ADO.NET 连接mySql成功步骤
VS2013使用EF6通过ADO.NET 连接mySql成功步骤 1.安装mysql-for-visualstudio-1.2.6(我用的目前最新版,这个一般安装VS2013就已经有了,没有的话下载一 ...
- VS2010/VS2013项目创建及通过ADO.NET连接mysql/sql server步骤(VS2013连接成功步骤见上一篇随笔)
本随笔主要是对初学者通过ADO.NET连接数据库的步骤(刚开始我也诸多不顺,所以总结下,让初学者熟悉步骤) 1.打开VS新建一个项目(这里的VS版本不限,建项目都是一样的步骤) VS2010版本如图: ...
- codesmith 连接mysql
下载地址是http://dev.mysql.com/downloads/mirror.php?id=403020 请先注册登录后才能下载mysql-connector-net-6.3.7.msi这个文 ...
- C++连接mysql的两种方式(ADO连接和mysql api连接)
一.ADO连接mysql 1.安装mysql-5.5.20-win32.msi和mysql-connector-odbc-5.3.4-win32.msi(一般两个安装程序要匹配,否则可能连接不上) ...
- C++ ADO 连接 mysql
1.安装mysql-5.0.22-win32,mysql-connector-odbc-5.1.12-win32.msi 然后:开始菜单->设置->控制面板->管理工具-> ...
- VC++ ADO 连接 mysql
通过自己摸索和网上帮助 了解了VC++ 用ADO 连接mysql数据库的方法: 使用的方法是利用ADO通过建立ODBC数据源来最终达到访问MySQL的目的. 1.安装mysql数据库服 ...
- C# 3种方法连接MySql
转 http://wenku.baidu.com/view/d0cf34708e9951e79b8927c7.html C# 连接MYSQL数据库的方法及示例 连接MYSQL数据库的方法及示例 方 ...
- 使用EntityFramework6连接MySql数据库(db first方式)
准备工具: VS2013.MySQL For VisualStudio 1.1.4.Connector/Net 6.8.3(百度网盘里) 程序包管理器执行命令: Install-Package Ent ...
- 转:ADO.NET连接字符串
名称 ADO.NET连接字符串 说明 ADO.NET连接字符串:SQL Server,SQL Server 2005,ACCESS,Oracle,MySQL,Interbase,IBM DB2,Syb ...
随机推荐
- LeetCode Problem 2:Two Sum
描述: Given an array of integers, find two numbers such that they add up to a specific target number. ...
- MVC架构模式概述
MVC MVC概述: Model–view–controller (MVC) is a software architectural pattern for implementing user int ...
- 1603 限高二叉排列树(计数DP)
1603 限高二叉排列树 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 作为游戏魔方的编写者和管理员,Bob在很多主存模块中 ...
- jPage.js分页
jPage.js插件使用文档 这一款插件主要是为了bootstrap原生的分页功能效果不理想而诞生的一款插件. jPage.js代码更新地址为:https://github.com/leslieSie ...
- c#调用c++带有回调函数方法的实现
最近完成了一个C++版本的对外sdk程序,其中有部分回调函数使用. C++程序使用时没有异常,但是在C#环境下使用时出了点问题,简单总结下. 感谢博客:http://blog.csdn.net/son ...
- javafx 普通弹框提示
new Alert(Alert.AlertType.NONE, "xxx不存在", new ButtonType[]{ButtonType.CLOSE}).show();
- Linux python3安装/shell脚本/if/循环/函数
python3安装 安装过程 安装包: wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgztar -xvf Python-3.7 ...
- open-falcon 前端代码在windows上运行
1: 下载代码git clone https://github.com/open-falcon/dashboard.git 2:在代码\dashboard-0.2.0 的根目录下安装 python虚拟 ...
- 字符串之strstr
功能:查找第二个字符串是否存在第一个字符串中. 输入:字符串1,字符串2 返回值:成功返回str1中的位置,失败返回NULL #include <iostream> using names ...
- 4.2 使用STM32控制MC20发送短信
需要准备的硬件 MC20开发板 1个 https://item.taobao.com/item.htm?id=562661881042 GSM/GPRS天线 1根 https://item.taoba ...