【发布时间】:2017-09-06 15:06:53
【问题描述】:
我想从我的 c# windows 窗体应用程序连接到数据库。我尝试使用
using(SqlConnection conn = new SqlConnection()) {
conn.ConnectionString = "Data Source=localhost; User Id=root; Password=; Initial Catalog=dbName";
conn.Open();
}
当我构建我的项目时,我收到一个错误 server wasn't found or wasn't accessible。
我尝试通过数据源配置向导连接,但也找不到数据库。
我使用WAMP服务器,可以通过phpMyAdmin找到我的数据库。
【问题讨论】:
-
发生了什么错误?
-
@SachithMW 这是一个运行时错误,上面写着:
Unhandled exception has occured in your application ... ... A network-related or instance-specific error occurred while establishing a connection to SQL server. The server was not found or was not accessible. ...
标签: c# mysql database visual-studio wamp