0.文档
https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff648951(v=pandp.10)?redirectedfrom=MSDN
1.DLL: (sqlserver只需前面两个)
Microsoft.Practices.EnterpriseLibrary.Common 6.0.0.0
Microsoft.Practices.EnterpriseLibrary.Data 6.0.0.0
MySql.Data 6.9.9
安装对应版本对应系统的Mysql Connector/NET --mysql官方网站下载 重点!重点!重点! ----大坑整了一天!
2.配置文件:
providerName="System.Data.SqlClient" />
3.使用:
DatabaseProviderFactory factory = new DatabaseProviderFactory();
//Database defaultDB = factory.Create("ExampleDatabase");
Database defaultDB = factory.CreateDefault();
string sql1 = @"insert into alarm_fields (FieldName,FieldDescription) values(‘xk‘,‘测试3333‘)";
string sql = @"sekect * from alarm_fields";
int r= defaultDB.ExecuteNonQuery(CommandType.Text, sql1);
4.# 各种封装好的方法见程序
原文:https://www.cnblogs.com/hx215267863/p/12343906.html