Click here to Skip to main content
15,670,482 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

' 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=,1433;Network=TCP/IP;Initial Catalog=phoneix;Integrated Security=SSPI;user Id=sa;Password=welcome")
   ' Public con As New SqlConnection("Data Source=,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
Updated 6-Jan-12 23:41pm
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
->Test connection and see if any error occurs share that error


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
Sridhar Patnayak 7-Jan-12 6:03am    
Good solution - 5
uspatel 7-Jan-12 6:13am    
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[^]

Share this answer
devausha 7-Jan-12 5:48am    
I checked all of the connection string but it is not working
Your connect string should be :
Public con As New SqlConnection("Data Source=;Initial Catalog=phoneix;Integrated Security=SSPI;")
Share this answer
Public con As SqlConnection = New SqlConnection("Data Source=,1433;Network Library=DBMSSOCN;Initial Catalog=mydatabase;User ID=sa;Password=************;")
Share this answer
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