通过IP地址与sql server连接 [英] connect with sql server through IP address
问题描述
亲爱的朋友们我想通过IP地址连接sql server我的意思是在同一个局域网中的其他电脑上安装sql,在我的电脑上安装c#。现在我想与两者联系。我有正确的代码...
__________________________________________________________________________________
Dear Friends I want to connect sql server through IP address i means sql install in other pc in same Lan network and c# install in my PC. Now i want to connect with both. I have right following code...
__________________________________________________________________________________
string Connection = "Data Source= dell-pc; User ID = sa; Password= mkj@123; Initial Catalog= asset; Network Address= 192.168.22.136 ; Network Library=dbmssocn; Trusted_Connection=yes; Integrated Security=SSPI";
SqlConnection Connections = new SqlConnection(Connection);
Connections.Open();
MessageBox.Show("Success.......");
___________________________________________________________________________________
此代码显示以下错误:
登录失败。登录来自不受信任的域,不能与Windows身份验证一起使用。
请将
___________________________________________________________________________________
and this code showing following error:
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
Please helo
推荐答案
你必须在DataSource而不是Dell-pc中提供你的服务器名称
它应该是这样的:
Yoou have to give your server name in DataSource instead of Dell-pc
it should be something like this:
Data Source=192.168.22.136,1433;Network Library=DBMSSOCN;Initial Catalog=asset;
User ID=sa;Password=mkj@123;
数据末尾Source是要使用的端口。 1433是SQL Server的默认端口。
At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
尝试此
string Connection ="Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;";
试试这个...
Try this...
//if "IntegratedSecurity" is false
string conStr = "Data Source=192.168.11.11; User Id=uid; Password=pwd; Database=databasename";
// otherwise
string conStr = "Data Source=192.168.11.11; Integrated Security=SSPI; Database=databasename";
using(SqlConnection con = new SqlConnection(conStr))
{
con.Open();
}
这篇关于通过IP地址与sql server连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!