Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have written this provider to connect my database but I don't know how can connect on another pc

I arranged the necessary TCPIP from ConfigurationManager on the target server.I opened the required ports(1433 and 1434). I shut down windows firewall but I can't connect

What I have tried:

SqlConnection baglanti = new SqlConnection();
SqlConnectionStringBuilder bagla = new SqlConnectionStringBuilder();
bagla.InitialCatalog = dbname;
bagla.DataSource = @".\SQLEXPRESS";
bagla.IntegratedSecurity = true;
baglanti.ConnectionString = bagla.ConnectionString;
return baglanti;
Posted
Updated 11-May-18 1:42am
v2

1 solution

bagla.DataSource = @"ServerNameHere\SQLEXPRESS";


The "." in your connection means the local machine, so replace it with the name\IP\whatever of the target machine. Note that machine needs to be configured to allow remote access etc, and this also assumes the instance is called SQLEXPRESS on that machine too. Change the instance name if required.
 
Share this answer
 
v2
Comments
GamzeAytac 11-May-18 7:23am    
SqlConnection baglanti = new SqlConnection();
SqlConnectionStringBuilder bagla = new SqlConnectionStringBuilder();
bagla.InitialCatalog = dbname;
bagla.DataSource = @"192.168.1.26\SQLEXPRESS";
bagla.IntegratedSecurity = true;
baglanti.ConnectionString = bagla.ConnectionString;
return baglanti;


I tried to connect again but I still have some problem
F-ES Sitecore 11-May-18 7:27am    
What problem? You haven't explained a problem, you haven't given details of error messages you receive or anything. The target server needs to be properly configured to allow remote connections and it needs SQL Express installed and running. Google "connect sqlexpress remotely" and you'll find articles that detail the configuration you might need to do.
GamzeAytac 11-May-18 7:43am    
I arranged the necessary TCPIP from ConfigurationManager on the target server.I opened the required ports(1433 and 1434). I shut down windows firewall
Richard Deeming 11-May-18 9:34am    
Did you configure the SQL Server instance to allow remote connections?
How to configure SQL Server 2005 to allow remote connections[^]

If you have, then you need to give us the full error details, not just "it's not working".
GamzeAytac 15-May-18 6:59am    
I arranged the edits step by step. Everybody writes the same things everywhere. I tried again and again. I still get the error.
A network related or instance specific error occured while establishing a connection to SQL Server. The server was not found or was not accessible

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