Dovberman
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(strConnectio n);
SqlCommand cmd = new SqlCommand(pstrSymbolNameS QL, conGetColValue);
// Try to open database and read information.
SqlDataAdapter adpSymbol = new SqlDataAdapter();
adpSymbol.SelectCommand = new SqlCommand(pstrSymbolNameS QL, 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(rowQuote History["C losePrice" ]);
// int intTradeVolumePrev = 0;
string strColValue = rowSymbol[pstrColName].ToS tring();
// DateTime dteQuoteDate = Convert.ToDateTime(rowQuot eHistory[" 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,
private string GetColValue(string pstrSymbolNameSQL, string pstrColName)
// Gets column value based on the SQL Select string
{
string strConnection = connString.ToString();
SqlConnection conGetColValue = new SqlConnection(strConnectio
SqlCommand cmd = new SqlCommand(pstrSymbolNameS
// Try to open database and read information.
SqlDataAdapter adpSymbol = new SqlDataAdapter();
adpSymbol.SelectCommand = new SqlCommand(pstrSymbolNameS
DataSet dstSymbol = new DataSet();
adpSymbol.Fill(dstSymbol, "RowData");
if (dstSymbol.Tables[0].Rows.
{
return "None";
}
else
{
DataRow rowSymbol = dstSymbol.Tables[0].Rows[0
// decimal decClosePrice = Convert.ToDecimal(rowQuote
// int intTradeVolumePrev = 0;
string strColValue = rowSymbol[pstrColName].ToS
// DateTime dteQuoteDate = Convert.ToDateTime(rowQuot
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great article on connection pool management. Answers all my questions.
Thanks.
Thanks.
ASKER
Thanks.