Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am already asked this question, but still now i cannot connected to network sql server

I give the following coding and check it. But it is not connected

VB
' Public con As New SqlConnection("Data Source=SQLSERVER\SQLEXPRESS;Initial Catalog=phoneix;Integrated Security=True")
   'Public con As New SqlConnection("Server=SQLSERVER\\SQLEXPRESS,10000;SSPI=True;Initial Catalog=phoneix;User Id=sa;Password=welcome")
   'Public con As New SqlConnection("Integrated Security=SSPI;Initial Catalog=phoneix;Data Source=SQLSERVER\SQLPRESS;User Id=sa;Password=welcome")
   Public con As New SqlConnection("Data Source=192.170.1.53,1433;Network=TCP/IP;Initial Catalog=phoneix;Integrated Security=SSPI;user Id=sa;Password=welcome")
   ' Public con As New SqlConnection("Data Source=192.170.1.53,1433;Network=TCP/IP;Initial Catalog=phoneix;User Id=sa;Password=welcome;Trusted Connection=False")


And i have check the server is on the remote connections.
But the server is not connected. The following error will occured,
The type initializer for 'WindowsApplication1.Module1' threw an exception.

Is there any change made to sql server,Please anybody have solution for this help me
Please help anybody help for this problem

Thanks in advance
Posted
Updated 6-Jan-12 23:41pm
v4
Comments
Simon_Whale 7-Jan-12 19:15pm    
Can you connect to the database from SQL Server management studio?

Try these steps and see if any error message occurs
open visual studio
->Server explorer
->Add connection
->new connection
->change to sql server
->Provide server name 92.170.1.53
->Test connection and see if any error occurs share that error

else

after successfull connection
right click on server explorere database connection ->properties

see Connection String
copy it and use.......


hope it will helps.
 
Share this answer
 
Comments
Sridhar Patnayak 7-Jan-12 6:03am    
Good solution - 5
uspatel 7-Jan-12 6:13am    
thanks......
devausha 7-Jan-12 7:03am    
I have tried but it is not connected

Please reply what can i do
Dear devausha,

Check your connection string with
http://www.connectionstrings.com/sql-server-2005[^]

Thanks
 
Share this answer
 
Comments
devausha 7-Jan-12 5:48am    
I checked all of the connection string but it is not working
Your connect string should be :
VB
Public con As New SqlConnection("Data Source=192.170.1.53;Initial Catalog=phoneix;Integrated Security=SSPI;")
 
Share this answer
 
Public con As SqlConnection = New SqlConnection("Data Source=192.168.174.128,1433;Network Library=DBMSSOCN;Initial Catalog=mydatabase;User ID=sa;Password=************;")
 
Share this answer
 
Comments
Nelek 4-Aug-15 17:13pm    
3 years late :)

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