Re: What's the best way to open a recordset for insert only?
- From: Spencer <Spencer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 11 Apr 2008 07:40:03 -0700
As it turns out, it was necessary to close and reopen the recordset
periodically. I really don't think I would have come across this if I
hadn't picked at the thing like an itchy scab.
This is where "ADO choking on that much data" came into play. I found that
the recordset object leaked memory to the extent that the program eventually
crashed. To implement your suggestion, I tried:
1. After verifying the table structure
Set m_active_rs.activeconnection = Nothing
m_conn.Close
2. Just before UpdateBatch:
m_conn.open
Set m_active_Rs.activeconnection = m_conn
3. Just after UpdateBatch, do the stuff in step 1.
Unfortunately, this did not stop the memory leak. If, instead, you close
and reopen m_active_rs after every UpdateBatch, memory usage appears to be
stable. I'm only getting 800-1200 records per tick now, but I hope that
improves in the production environment.
"Bob Barrows [MVP]" wrote:
I should have added that you could close that connection while the
recordset was disconnected, and then reopen it just before reconnecting
it.
Spencer wrote:
Just in case you were wondering, the application is now inserting
3000-4000 records in the test environment per tick of the progress
bar/call to BatchUpdate. Setting rs.ActiveConnection to Nothing
between batches doesn't seem to improve that significantly.
"Bob Barrows [MVP]" wrote:
Spencer wrote:
So it was a failed experiment, and it looks like I'll have to use
the recordset. But I'm wondering if there's a way to open the
recordset so that I can call AddNew on it, but doesn't query the
entire table first.
Use a disconnected recordset opened using a sql query that includes
"WHERE 1=2"
rs.CursorLocation = adUseClient
m_rsname = "select <fields> from " & m_rsname & " WHERE 1=2"
rs.Open m_rsname, m_conn, , adLockBatchOptimistic, adCmdText
Set rs.ActiveConnection = Nothing
'add your records, then
Set rs.ActiveConnection = m_conn
rs.UpdateBatch
.
- References:
- What's the best way to open a recordset for insert only?
- From: Spencer
- Re: What's the best way to open a recordset for insert only?
- From: Bob Barrows [MVP]
- Re: What's the best way to open a recordset for insert only?
- From: Spencer
- Re: What's the best way to open a recordset for insert only?
- From: Bob Barrows [MVP]
- What's the best way to open a recordset for insert only?
- Prev by Date: Re: Designer generated code fails to compile
- Next by Date: Memory leak in ado
- Previous by thread: Re: What's the best way to open a recordset for insert only?
- Next by thread: Re: What's the best way to open a recordset for insert only?
- Index(es):
Relevant Pages
|
|