刚刚学习.net core2,用dapper+mysql操作数据库,但是一直连不上去,提示“ArgumentException: Format of the initialization string does not conform to specification starting at index 0.”,不知道什么原因,只配置了appseting.json:,后台代码是这样写的:
"ConnectionStrings": {
"DefaultConnection": "server=locahostl;post=3306;database=blog;user=root;password=123456"
},
public static MySqlConnection GetConnection()
{
using (MySqlConnection conn = new MySqlConnection("DefaultConnection"))
{
conn.Open();
return conn;
}
}
连接字符串不对.
https://www.connectionstrings.com/mysql/
如果你配置了 appSettings.json,那就需要从appSettings.json中把数据读取出来,建议先去看看 https://github.com/dotnet-architecture/eShopOnContainers
不能这样
– dudu 6年前return conn
@dudu: 在using那里就出错了
– 灬丶 6年前