Re: Stack Overflow on Insert
Jeff Nygren <[email protected]> Thu, 30 May 2002 10:11:18 -0500
| Newsgroups | gmane.comp.windows.devel.oledb.devel |
|---|---|
| Message-ID | <[email protected]> |
Dave, Using the new ATL 7.0 conversion classes has solved my immediate problem of stack overflow errors, but I think you have discovered another large hole in my knowledge. I'm using a CCommand object to get an entire table from a MS Access database. I'm then 'Insert'ing many records into (the end of ???) the table. Should I be doing an 'Update' after each record inserted? (or frequent UpdateAll calls?) Is this happening automatically when I Close my CCommand (i.e. recordset)? How will performance be affected? I appreciate your help. Jeff Nygren At what point are you updating the table? Without explicitly calling the update of the recordset, you load up memory with all the changes until the UpdateBatch method is executed. This is particularly a problem if you open the recordset using a LockBatch type of parameter. To resolve this, you could issue the update with each record added, or key the updatebatch method to execute after a certain number of records have been added. Dave Edwinson -----Original Message----- From: Jeff Nygren [mailto:[email protected]] Sent: Friday, May 24, 2002 9:09 AM To: [email protected] Subject: Re: Stack Overflow on Insert ... Thank you for taking a look at this. Here are the 'guts' of my sample app. Jeff Nygren hr = DBOutputCommand.CreateAccessor(nOutputCols, &pszColumnBuf[1], sizeof(TCHAR)*nOutputCols*256); for (ULONG lCol = 1; lCol <= nOutputCols; lCol++) DBOutputCommand.AddBindEntry(lCol, DBTYPE_WSTR, 256, &pszColumnBuf[lCol]); CString sQuery("select * from tablename"); hr = DBOutputCommand.Open(m_DBOutputSession, sQuery, &PropertySet); // Loop through records for (nRecordNum = 0; nRecordNum < NUMROWS; nRecordNum++) { // Loop through columns of output database for (int iColumn = 0; iColumn < NUMCOLS; iColumn++) wcsncpy((WCHAR*)pszColumnBuf[iColumn + 1], (WCHAR*)T2OLE(strValue), 128); if (S_OK == (hr = DBOutputCommand.Insert())) { ... -----Original Message----- From: Jeff Nygren [mailto:[email protected]] Sent: 23 05 2002 15:50 To: [email protected] Subject: [OLEDB_DEV] Stack Overflow on Insert I have some code that adds records to a MS Access database. If I try to add too many records, I get a stack overflow. I'm guessing there is something more I need to do, but I don't know what it is. My code is basically: ... You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other DevelopMentor lists at http://discuss.develop.com.