Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have developed a windows application with database on PC 1
the software is running will well , i setup the same software on PC 2
and i don't know how make the software on PC 2 see the database of PC 1

how should i make the connection string ???

i try many things like this :

HTML
ConnectionString = "Network Library=DBMSSOCN;" & _
                            "Data Source=xxx.xxx.xxx.xxx,1433;" & _
                            "Initial Catalog=mySQLServerDBName;" & _
                            "User ID=myUsername;" & _
                            "Password=myPassword"


Where:
- "Network Library=DBMSSOCN" tells SqlConnection to use TCP/IP
- xxx.xxx.xxx.xxx is an IP address.
- 1433 is the default port number for SQL Server
- You can also add "Encrypt=yes" for encryption
</b>

it doesn't work :(
Posted
Updated 18-Apr-12 3:23am
v2
Comments
[no name] 18-Apr-12 9:27am    
"it doesn't work" is not a very helpful description of your problem. What doesn't work? What errors are you getting? What exceptions are you seeing?

 
Share this answer
 
Comments
VJ Reddy 18-Apr-12 19:51pm    
ConnectionStrings.com is really a good reference. 5!
Mohammad A Rahman 18-Apr-12 20:03pm    
Thank you VJ :)
Anas Bassam 21-Apr-12 13:28pm    
thank you so much my brother ;)
Mohammad A Rahman 21-Apr-12 17:52pm    
Thank you :)
change security authentication mode

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.

On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.

In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

To enable the sa login

In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.

On the General page, you might have to create and confirm a password for the login.

On the Status page, in the Login section, click Enabled, and then click OK.

and then make your connection string as the following :

add name ="Connection_String" providerName="System.Data.SqlClient" connectionString="Data Source=xxx.xxx.x.xxx,1433;Initial Catalog=DatabaseName;Persist Security Info=True;User ID=UID;Password=password "

and its worked :)
 
Share this answer
 
Comments
Abhinav S 21-Apr-12 13:48pm    
Thanks for providing the solution. You might want to write a little tip / trick for this. Could help others in strife!
Nelek 21-Apr-12 18:02pm    
I agree with Abhinav, that could help other users. You should write a tip/trick
Hi,
First you need to allow remote connection. Go to following link :
support.microsoft.com/kb/914277

Then you can access it using IP address like, "Data Source=192.168.155.144\SQLEXPRESS;User Id=sa;Password=pass;Initial Catalog=test"
 
Share this answer
 
Comments
Anas Bassam 21-Apr-12 13:30pm    
thank you deepak_Sharma your info was very useful
thank u
It could be as simple as firewall issue on your PC1. Did you check if port 1433 on xxx.xxx.xxx.xxx,1433 is open and your PC2 could connect to it?
 
Share this answer
 
Comments
Anas Bassam 21-Apr-12 13:35pm    
dear Eugene thank you soooooooooooooooooooooooooo much your assumption was true ,
i check the port and add it as a role in the firewall to be always allowed
then i check the following steps :
i change the security authentication mode
and To change security authentication mode

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.

On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.

In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

To enable the User login

In Object Explorer, expand Security, expand Logins, right-click <user name="">, and then click Properties.

On the General page, you might have to create and confirm a password for the login.

On the Status page, in the Login section, click Enabled, and then click OK.

and finally i change the connection string to :




connectionstring="Data Source=xxx.xxx.x.xxx,1433;Initial Catalog=DatabaseName;Persist Security Info=True;User ID=UID;Password=password"



and its worked ;)

AND AGAIN
THANK YOU SOOOOOOOO MUCH Eugene
phil.o 21-Apr-12 13:53pm    
Don't forget to vote for the answer if it actually helped you. This way the one who helped you will get reputation points.
Eugene Sadovoi 21-Apr-12 13:53pm    
You are welcome. I am glad I was able to help.

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