I am tried to connect to a database server with tcp port and public ip, but at time to open connection get next error: "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." The windows server have port open in firewall and this port is added in SQL Configuration Manager > TCP/IP > IP Addresses > IP ALL TCP PORT. I hope that you can help me. Thanks.
The C# code is:
public DataTable FillDataTable(string table)
{
string query = "SELECT * FROM " + table + ";";
string conSTR = @"Data Source=tcp:xxx.xxx.xxx.xxx,xxxx; Initial Catalog=WorkFlow;
User id=admin; Password=admin01;";
DataTable dt = new DataTable();
try
{
using (SqlConnection sqlConn = new SqlConnection(conSTR))
using (SqlCommand cmd = new SqlCommand(query, sqlConn))
{
cmd.CommandTimeout = 30;
sqlConn.Open();
dt.Load(cmd.ExecuteReader());
}
}
catch (Exception exc)
{
string msg = exc.Message.ToString();
}
return dt;
}