Click here to Skip to main content
15,881,757 members
Home / Discussions / Database
   

Database

 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Member 1332584628-Oct-20 0:26
Member 1332584628-Oct-20 0:26 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Jörgen Andersson28-Oct-20 2:15
professionalJörgen Andersson28-Oct-20 2:15 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Member 1332584629-Oct-20 18:47
Member 1332584629-Oct-20 18:47 
AnswerRe: The Best Free Database for real-time data storing and querying Pin
Mycroft Holmes28-Oct-20 12:07
professionalMycroft Holmes28-Oct-20 12:07 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Member 1332584629-Oct-20 18:56
Member 1332584629-Oct-20 18:56 
AnswerRe: The Best Free Database for real-time data storing and querying Pin
Gerry Schmitz30-Oct-20 8:40
mveGerry Schmitz30-Oct-20 8:40 
AnswerRe: The Best Free Database for real-time data storing and querying Pin
Eddy Vluggen26-Jan-21 12:36
professionalEddy Vluggen26-Jan-21 12:36 
QuestionDatabase ADO exception on adding new record Pin
Peter Mortier16-Oct-20 4:21
Peter Mortier16-Oct-20 4:21 
Hi,
when writing in Access database using ADO and record binding, I run into an exception after some time.
I wrote a small console program to demonstrate the problem :

C++
#include <Windows.h>
#include <iostream>
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#include "icrsint.h"
_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));

void OpenDatabase();
void WriteToDatabase(int i);
void CloseDatabase();

_ConnectionPtr m_pConnectionPtr = 0;
DWORD64 cnt_recordset;

int main()
{
  HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  m_pConnectionPtr = NULL;
  m_pConnectionPtr.CreateInstance(__uuidof(Connection));
  int cnt = 0;
  cnt_recordset = 0;

  OpenDatabase();
  while (1)
  {
    std::cout << cnt++ << " : " << cnt_recordset << std::endl;
    for (int i = 0; i < 1000; i++)
      WriteToDatabase(i);
  }
  CloseDatabase();
  CoUninitialize();
}

void OpenDatabase()
{
  bstr_t strCnn("Provider=MSDASQL;DSN=TestDB;User ID=sa;");
  m_pConnectionPtr->Open(strCnn, "", "", NULL);
}

void CloseDatabase()
{
  if ((m_pConnectionPtr->State == adStateOpen))
    m_pConnectionPtr->Close();
}

void WriteToDatabase(int i)
{
  cnt_recordset++;
  class CMyRecordSet : public CADORecordBinding
  {
    BEGIN_ADO_BINDING(CMyRecordSet)

      // Column m_nID is the 1st field in the table.
      ADO_VARIABLE_LENGTH_ENTRY2(1, adInteger, m_nID, sizeof(m_nID), m_IDStatus, FALSE)

      // Column m_bCritical is the 2nd field in the table.
      ADO_FIXED_LENGTH_ENTRY(2, adInteger, m_value, m_valueStatus, TRUE)

      END_ADO_BINDING()

  public:
    int			m_nID;
    int			m_value;
    ULONG		m_IDStatus;
    ULONG		m_valueStatus;
  };

  HRESULT hr = true;
  // open recordset
//_RecordsetPtr  pRs = NULL;
//pRst.CreateInstance(__uuidof(Recordset));

  _RecordsetPtr pRs("ADODB.Recordset");
  CMyRecordSet rs;
  IADORecordBindingPtr picRs(pRs);
  hr = pRs->Open("TTagData",
                 _variant_t((IDispatch*)m_pConnectionPtr, true),
                  adOpenKeyset, adLockOptimistic, adCmdTable);
  //Bind the Recordset to a C++ Class here.
  hr = picRs->BindToRecordset(&rs);
  // fill in data
  rs.m_value = i;
  // add new record to the table
  picRs->AddNew(&rs);
  // picRs->Release(); tried this but no result

  pRs->Close();
}


The exception occurs on closing the recordset after the AddNew :
inline HRESULT Recordset15::Close ( ) {
    HRESULT _hr = raw_Close();
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return _hr;
}

Exception number is 0x800a0c93

This happens after a couple of hundreds of thousends writes.


Am I missing something?
Any help is appreciated very much!
GeneralRe: Database ADO exception on adding new record Pin
Richard MacCutchan16-Oct-20 4:53
mveRichard MacCutchan16-Oct-20 4:53 
AnswerRe: Database ADO exception on adding new record Pin
CHill6016-Oct-20 5:18
mveCHill6016-Oct-20 5:18 
GeneralRe: Database ADO exception on adding new record Pin
Peter Mortier19-Oct-20 1:58
Peter Mortier19-Oct-20 1:58 
AnswerRe: Database ADO exception on adding new record Pin
Peter Mortier19-Oct-20 2:00
Peter Mortier19-Oct-20 2:00 
GeneralRe: Database ADO exception on adding new record Pin
Victor Nijegorodov19-Oct-20 7:07
Victor Nijegorodov19-Oct-20 7:07 
GeneralRe: Database ADO exception on adding new record Pin
Peter Mortier20-Oct-20 8:40
Peter Mortier20-Oct-20 8:40 
GeneralRe: Database ADO exception on adding new record Pin
Victor Nijegorodov20-Oct-20 9:29
Victor Nijegorodov20-Oct-20 9:29 
QuestionDatabase design and custom query for this use case ? Pin
karengsh13-Oct-20 23:17
karengsh13-Oct-20 23:17 
QuestionShould I store files in a database? Pin
Member 1260015012-Oct-20 22:37
Member 1260015012-Oct-20 22:37 
AnswerRe: Should I store files in a database? Pin
Richard Deeming12-Oct-20 22:54
mveRichard Deeming12-Oct-20 22:54 
QuestionMYSQL Pin
Member 147129666-Oct-20 10:21
Member 147129666-Oct-20 10:21 
AnswerRe: MYSQL Pin
ZurdoDev6-Oct-20 10:34
professionalZurdoDev6-Oct-20 10:34 
QuestionDatabase scripts version control process/strategy? Pin
Member 1363071429-Sep-20 6:06
Member 1363071429-Sep-20 6:06 
AnswerRe: Database scripts version control process/strategy? Pin
David Mujica29-Sep-20 7:48
David Mujica29-Sep-20 7:48 
AnswerRe: Database scripts version control process/strategy? Pin
ZurdoDev29-Sep-20 9:05
professionalZurdoDev29-Sep-20 9:05 
QuestionSimple Database design Pin
fdanos23-Sep-20 20:23
professionalfdanos23-Sep-20 20:23 
AnswerRe: Simple Database design Pin
Victor Nijegorodov23-Sep-20 20:54
Victor Nijegorodov23-Sep-20 20:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.