为什么Npgsql有时没有响应?

为什么Npgsql有时没有响应?,npgsql,Npgsql,I使用Npgsql 3.2.2 我连接到Web服务器的数据库: <add key="CONNECTION_STRING_WEBSERVER" value="Server=abctest.com;Port=5432;UserId=postgres;Password=postgres;Database=testdatabase;CommandTimeout=300;" /> 我的职能: private DataTable getData(string tableName)

I使用Npgsql 3.2.2 我连接到Web服务器的数据库:

   <add key="CONNECTION_STRING_WEBSERVER" value="Server=abctest.com;Port=5432;UserId=postgres;Password=postgres;Database=testdatabase;CommandTimeout=300;" />
我的职能:

private DataTable getData(string tableName)
    {
        DataSet ds = null;
        DataTable tbl = null;

        try
        {

            if (m_ConnectionExecute == null)
            {
                 m_ConnectionExecute = new NpgsqlConnection(m_connString_web);                 

            }
            if (m_ConnectionExecute.State != ConnectionState.Open)
            {
                m_ConnectionExecute.Open();               
            }

            NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();            
            NpgsqlCommand command = null;
            try
            {
                command = CreateCommand(m_Parameters);
                command.CommandText = m_commText;
                command.Connection = m_ConnectionExecute;
                adapter.SelectCommand = command;

                ds = new DataSet();
                adapter.Fill(ds, "Table1");
                tbl = ds.Tables[0];
                tbl.TableName = tableName;
                ds.Tables.Clear();

            }
            catch (SqlException ex)
            {
                ds = null;
            }
            finally
            {
                if ( m_ConnectionExecute != null && m_ConnectionExecute.State != ConnectionState.Closed)
                {
                    m_ConnectionExecute.Close();                   
                }
            }
        }
        catch (Exception e)
        {

            ds = null;
            tbl = null;
        }      

        return tbl;
    }
我使用定时器:5s将调用函数
getData

但有时,函数getData没有响应,我的程序无法继续下一个进程

只有当计时器运行几天并且数据库放在web服务器上时,问题才会出现。 注:我有5个定时器运行自动访问数据库

原因是什么?还是postgresql的限制?
为什么Npgsql有时没有响应?

Wow。两个例外条款。如何删除它们以获取实际原因?我尝试从Visual Studio 2012运行程序,如果单击“暂停”,它将在第行停止:NpgsqlDataAdapter=new NpgsqlDataAdapter()@UweKeim是对的,修改代码使异常冒泡而不是吞噬它们,这样您就知道实际发生了什么。NpgsqlDataAdapter的实例化不太可能以任何方式阻塞-那里什么都没有发生。如果发生异常,计时器将不会停止。问题是Ngpsql没有重新发送。所以它无法完成函数getData。
private DataTable getData(string tableName)
    {
        DataSet ds = null;
        DataTable tbl = null;

        try
        {

            if (m_ConnectionExecute == null)
            {
                 m_ConnectionExecute = new NpgsqlConnection(m_connString_web);                 

            }
            if (m_ConnectionExecute.State != ConnectionState.Open)
            {
                m_ConnectionExecute.Open();               
            }

            NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();            
            NpgsqlCommand command = null;
            try
            {
                command = CreateCommand(m_Parameters);
                command.CommandText = m_commText;
                command.Connection = m_ConnectionExecute;
                adapter.SelectCommand = command;

                ds = new DataSet();
                adapter.Fill(ds, "Table1");
                tbl = ds.Tables[0];
                tbl.TableName = tableName;
                ds.Tables.Clear();

            }
            catch (SqlException ex)
            {
                ds = null;
            }
            finally
            {
                if ( m_ConnectionExecute != null && m_ConnectionExecute.State != ConnectionState.Closed)
                {
                    m_ConnectionExecute.Close();                   
                }
            }
        }
        catch (Exception e)
        {

            ds = null;
            tbl = null;
        }      

        return tbl;
    }