i have SQL server express 2012 installed on windows 10 64 bit, the connection from same computer worked fine, problem when i connect from another computer on same network, i get error message:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connection
-provider TCP provider error 0 the wait operation timeout
i try the following things but not fix the problem:
- Enable and automaticly start SQL Browser
- Enbale TCP/IP and set port 1433 for all IP types
- Start Named inslance SQLExpress2012 autmaticaly as Build-in : Network service
- connect without user and password with IntegratedSecurity=true
- The database is using mixed-mode authentication
- add an exception in the firewall for port 1433
- enable named pipe
- allow remote connection
this is my code:
public static bool TestSQLServerConnection(
string ComputerNameOrIPAddress,
string SQLServerInstanceName,
string PortNumber)
{
try
{
SqlConnectionStringBuilder SQLServerConnectionString = new SqlConnectionStringBuilder();
SQLServerConnectionString.DataSource = ComputerNameOrIPAddress+",+"+PortNumber+"\\"+SQLServerInstanceName;
SQLServerConnectionString.InitialCatalog = DatabseName;
SQLServerConnectionString.TrustServerCertificate = true;
SQLServerConnectionString.IntegratedSecurity = true;
//SQLServerConnectionString.UserID = "...";
//SQLServerConnectionString.NetworkLibrary = "DBMSSOCN";
//SQLServerConnectionString.Password = "...";
SqlConnection con = new SqlConnection(SQLServerConnectionString.ConnectionString);
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText= "select 1";
con.Open();
cmd.ExecuteScalar();
con.Close();
return true;
}
catch (Exception ex)
{
throw ex;
}
}
when i ping the ip address or computer name of computer of SQL Server it connected and return response, means the computer is connected to network. i search for while without any solution, please help me.Thanks