I've seen the same problem. It has to be you not closing your connections. It might be throwing an exception, which in that case you still need to close the connection. Here's a sample of what I use.
Taken from:
http://cvs.sourceforge.net/viewcvs.py/tagelflax/tagml/TAGMLWS/DbLayer/connection.cs?view=markup
static public Action[] GetLastActionList(ref UInt32 workspaceId,
ref Int64 lastActionId)
{
ArrayList newActionList = new ArrayList();
IDbConnection myConnection = DBFactory.CreateConnection();
myConnection.Open();
try
{
IDbCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = "LOCK TABLES tagml_action READ";
myCommand.ExecuteNonQuery();
myCommand = myConnection.CreateCommand();
// Causes scan instead of seek for now
myCommand.CommandText = "SELECT ActionId,TypeId,TableId,TableIndex FROM tagml_action WHERE WorkspaceId=?workspace AND ActionId>?actionid";
IDbDataParameter p = myCommand.CreateParameter();
p.ParameterName = "?workspace";
p.Value = workspaceId;
AddDbTypeToParameter(myCommand, p);
p = myCommand.CreateParameter();
p.ParameterName = "?actionid";
p.Value = lastActionId;
AddDbTypeToParameter(myCommand, p);
IDataReader reader = myCommand.ExecuteReader();
while(reader.Read())
{
Action newAction = new Action();
newAction.ActionId = (Int64)reader["ActionId"];
newAction.ActionType = (ActionTypeEnums)(Int16)reader["TypeId"];
newAction.Table = (TableEnums)(Int16)reader["TableId"];
newAction.TableIndex = (UInt32)reader["TableIndex"];
newActionList.Add(newAction);
}
reader.Close();
myCommand = myConnection.CreateCommand();
myCommand.CommandText = "UNLOCK TABLES";
myCommand.ExecuteNonQuery();
}
catch(Exception e)
{
myConnection.Close();
throw e;
}
myConnection.Close();
return (Action[])newActionList.ToArray(typeof(Action));
}