数据库连接字符串问题 [英] Database Connection String Problem
问题描述
您好我允许其他人连接到我的服务器。我正在运行服务器2008,我已经更改了所有设置以允许传入连接并遵循一些指南,但似乎都失败了。
此连接字符串工作正常在本地连接到数据库:
SqlConnection conn = new SqlConnection(Data Source = .\\SQLExpress; Initial Catalog = Food ;综合安全= SSPI;);
但是当我尝试将其替换为基于ip的连接字符串时:
SqlConnection conn = new SqlConnection(Data Source = ipaddy,1433; Network Library = DBMSSOCN; Initial Catalog = food;);
它完全崩溃我的程序,它根本不会加载。
如果有人能提供帮助,我会非常感谢你提前欢呼
你有2个错误
1)使用你的电脑用户名b4服务器名
错误
数据源=。\\SQLExpress;初始
ans
数据源= PC用户名\\SQLExpress;初始
cos(。)仅工作使用Sql 2000
2)使用@ b4连接字符串
SqlConnection conn = new SqlConnection( @ 数据源=。\\SQLExpress;初始目录=食品;集成安全性= SSPI;);
最终连接字符串将是
SqlConnection conn = new SqlConnection( @ 数据源= PC用户名\\SQLExpress;初始目录=食品;集成安全性= SSPI;);
检查服务器系统sql的用户名和密码。
尝试在web.config文件中存储连接字符串..
Hi I am having trouble with allowing others to connect to my server. I am running server 2008, I have changed all the settings to allow incoming connections and followed a few guides but all seem to have failed miserable.
This connections string works fine to connect to the db locally:
SqlConnection conn = new SqlConnection("Data Source=.\\SQLExpress;Initial Catalog=Food;Integrated Security=SSPI;");
however when I try and substitute it for a ip based connection string:
SqlConnection conn = new SqlConnection("Data Source= ipaddy,1433;Network Library=DBMSSOCN;Initial Catalog=food;");
it completly crashes my program and it won''t load at all.
If someone could help would be much appreciated cheers in advance
you have 2 error
1) use user name of your pc b4 the servername
error
Data Source=.\\SQLExpress;Initial
ans
Data Source=PC Username\\SQLExpress;Initial
cos (.) only work with Sql 2000
2) use @ b4 connection string
SqlConnection conn = new SqlConnection(@"Data Source=.\\SQLExpress;Initial Catalog=Food;Integrated Security=SSPI;");
And the Final Connection string will
SqlConnection conn = new SqlConnection(@"Data Source=PC Username\\SQLExpress;Initial Catalog=Food;Integrated Security=SSPI;");
check for the username and password for the server system sql.
try to store connection string in web.config file..
这篇关于数据库连接字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!