OleDbException System Resources Exceeded

The system resources exceeded error is not coming from the managed code, its coming from you killing your database (JET?)

You are opening way too many connections, way too fast...

Some tips:

  • Avoid round trips by not opening a new connection for every single command, and perform the inserts using a single connection.
  • Ensure that database connection pooling is working. (Not sure if that works with OLEDB connections.)
  • Consider using a more optimized way to insert the data.

Have you tried this?

using (OleDBConnection conn = new OleDBConnection(connstr))
{
    while (IHaveData)
    {
        using (OldDBCommand cmd = new OldDBCommand())
        {
            cmd.Connection = conn;
            cmd.ExecuteScalar();
        }
    }
}