OleDbException System Resources Exceeded

后端 未结 5 756
感动是毒
感动是毒 2020-12-11 04:07

The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = \"System Resources Ex

5条回答
  •  死守一世寂寞
    2020-12-11 04:25

    In addition to the above (connecting to the database only once), I would also like to make sure you're closing and disposing of your connections. As most objects in c# are managed wrt memory, connections and streams don't have this luxury always, so if objects like this aren't disposed of, they are not guaranteed to be cleaned up. This has the added effect of leaving that connection open for the life of your program.

    Also, if possible, I'd look into using Transactions. I can't tell what you're using this code for, but OleDbTransactions are useful when inserting and updating many rows in a database.

提交回复
热议问题