Home > Database > Mysql Tutorial > FluentData 连接Mysql_MySQL

FluentData 连接Mysql_MySQL

WBOY
Release: 2016-06-01 13:12:35
Original
1265 people have browsed it

FluentData 框架连接Mysql的示例

先写一个方法

public IDbContext QueryDB()        {            return new DbContext().ConnectionStringName("constr", new MySqlProvider());        }
Copy after login

调用示例
DataTable dt = QueryDB().Sql("select * from user").QuerySingle<datatable>();</datatable>
Copy after login

web.config的连接字符串的配置

<connectionstrings>    <add name="constr" connectionstring="Server=服务器地址;Database=表名;Uid=用户名;Pwd=密码;" providername="MySql.Data.MySqlClient;"></add>  </connectionstrings>
Copy after login

从网上下载Mysql.Data.dll 引用

到这里并不算完,如果运行程序会出现‘找不到请求的 .Net Framework Data Provider’的提示。这里需要下载驱动。

下载地址:http://dev.mysql.com/downloads/connector/net/

下载安装,完成。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template