Click here to Skip to main content
11,580,000 members (72,353 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL
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.......");

___________________________________________________________________________________

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 30-Jan-13 20:18pm
Edited 31-Jan-13 20:12pm
v2
Comments
Santhosh Kumar J at 31-Jan-13 2:34am
   
192.168.22.136 is your server name
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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;
At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
  Permalink  
v2
Comments
Edo Tzumer at 31-Jan-13 2:46am
   
5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try this
string Connection ="Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;";
  Permalink  
Comments
Edo Tzumer at 31-Jan-13 2:47am
   
5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 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();
}
  Permalink  
Comments
Edo Tzumer at 31-Jan-13 2:46am
   
5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

write your IP Adress in Datasource, That they said above
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 208
1 Frankie-C 170
2 Abhinav S 65
3 Sergey Alexandrovich Kryukov 65
4 Dave Kreskowiak 43
0 OriginalGriff 1,088
1 Sergey Alexandrovich Kryukov 750
2 Abhinav S 638
3 Suvendu Shekhar Giri 433
4 F-ES Sitecore 420


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100