Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

Database Connection Stays Open but Sleeping

A connection seems to close as required. However the connection stays open and sleeping until I use a server tool to delete it.

private string GetColValue(string pstrSymbolNameSQL, string pstrColName)
    // Gets column value based on the SQL Select string
    {
        string strConnection = connString.ToString();
        SqlConnection conGetColValue = new SqlConnection(strConnection);
        SqlCommand cmd = new SqlCommand(pstrSymbolNameSQL, conGetColValue);

        // Try to open database and read information.

        SqlDataAdapter adpSymbol = new SqlDataAdapter();
        adpSymbol.SelectCommand = new SqlCommand(pstrSymbolNameSQL, conGetColValue);

        DataSet dstSymbol = new DataSet();
        adpSymbol.Fill(dstSymbol, "RowData");

        if (dstSymbol.Tables[0].Rows.Count == 0)
        {
            return "None";
        }
        else
        {
            DataRow rowSymbol = dstSymbol.Tables[0].Rows[0];
            // decimal decClosePrice = Convert.ToDecimal(rowQuoteHistory["ClosePrice"]);
            // int intTradeVolumePrev = 0;

            string strColValue = rowSymbol[pstrColName].ToString();
            // DateTime dteQuoteDate = Convert.ToDateTime(rowQuoteHistory["QuoteDate"]);

            conGetColValue.Close();
            conGetColValue.Dispose();

            return strColValue;
        }
    }

189 dovberman  sleeping  0 8/19/2012 12:21:45 PM SELECT Count(*) As UpdateDone FROM DownLoadDates WHERE QuoteDate = '8/19/2012' AND MarketID = 2 Delete

Any ideas?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

Great article on connection pool management.  Answers all my questions.
Thanks.
Great article on connection pool management.  Answers all my questions.
Thanks.