Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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...

__________________________________________________________________________________
C#
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.......");


___________________________________________________________________________________

and this code showing following error:

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.


Please helo
Posted
Updated 31-Jan-13 20:12pm
v2
Comments
Santhosh Kumar Jayaraman 31-Jan-13 2:34am    
192.168.22.136 is your server name

Yoou have to give your server name in DataSource instead of Dell-pc

it should be something like this:
CSS
Data Source=192.168.22.136,1433;Network Library=DBMSSOCN;Initial Catalog=asset;
User ID=sa;Password=mkj@123;

At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
 
Share this answer
 
v2
Comments
Joezer BH 31-Jan-13 2:46am    
5+
try this
C#
string Connection ="Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;";
 
Share this answer
 
Comments
Joezer BH 31-Jan-13 2:47am    
5+
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();
}
 
Share this answer
 
Comments
Joezer BH 31-Jan-13 2:46am    
5+
 
Share this answer
 
write your IP Adress in Datasource, That they said above
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900