读书人

连接数据库有关问题

发布时间: 2012-02-14 19:19:19 作者: rapoo

连接数据库问题
string str_sqlconnection = "server=.\\SQLEXPRESS;Initial Catalog=XFGL;Integrated Security=false;uid=sa;pwd=789456;";
上面的样子能连接上,但是把.\\SQLEXPRESS改成127.0.0.1或者localhost就失败了,请问为什么?

[解决办法]
string str_sqlconnection = "server=127.0.0.1\\SQLEXPRESS;Initial Catalog=XFGL;Integrated Security=false;uid=sa;pwd=789456;";

而不是
string str_sqlconnection = "server=127.0.0.1;Initial Catalog=XFGL;Integrated Security=false;uid=sa;pwd=789456;";

[解决办法]

探讨
string str_sqlconnection = "server=127.0.0.1\\SQLEXPRESS;Initial Catalog=XFGL;Integrated Security=false;uid=sa;pwd=789456;";

而不是
string str_sqlconnection = "server=127.0.0.1;Initial Catalog=XFGL;I……

读书人网 >C#

热点推荐