A
Avi
Hi all,
My Connection string timeout was set to 5 sec but commands takes much longer
to timeout when there is no connection to the destination ip. Is the
timeout value only helps when the ip is reachable but the sql server is not,
or it should work also if the ip address is unreachable. If it should work
also when the ip is unreachable, why it does not work in my case?
Thanks a million,
Avi
public static int ExecCommand(string command, string ip)
{
if (String.IsNullOrEmpty(ip))
throw new ManualRedundancyException("IP address for database connection
cannot be null");
string connectionStr = "Data Source=" + ip + ";Initial
Catalog=master;Persist Security Info=True;User
ID=sa;Password=1210;Connection Timeout=5;";
using (SqlConnection cn = new SqlConnection(connectionStr))
{
using (SqlCommand cm = new SqlCommand(command, cn))
{
cn.Open();
int i = cm.ExecuteNonQuery();
return i;
}
}
}
My Connection string timeout was set to 5 sec but commands takes much longer
to timeout when there is no connection to the destination ip. Is the
timeout value only helps when the ip is reachable but the sql server is not,
or it should work also if the ip address is unreachable. If it should work
also when the ip is unreachable, why it does not work in my case?
Thanks a million,
Avi
public static int ExecCommand(string command, string ip)
{
if (String.IsNullOrEmpty(ip))
throw new ManualRedundancyException("IP address for database connection
cannot be null");
string connectionStr = "Data Source=" + ip + ";Initial
Catalog=master;Persist Security Info=True;User
ID=sa;Password=1210;Connection Timeout=5;";
using (SqlConnection cn = new SqlConnection(connectionStr))
{
using (SqlCommand cm = new SqlCommand(command, cn))
{
cn.Open();
int i = cm.ExecuteNonQuery();
return i;
}
}
}