Click here to Skip to main content
14,742,134 members
Home » Discussions » Database
   

Database

 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Member 1332584628-Oct-20 1:26
MemberMember 1332584628-Oct-20 1:26 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Jörgen Andersson28-Oct-20 3:15
professionalJörgen Andersson28-Oct-20 3:15 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Member 1332584629-Oct-20 19:47
MemberMember 1332584629-Oct-20 19:47 
AnswerRe: The Best Free Database for real-time data storing and querying Pin
Mycroft Holmes28-Oct-20 13:07
professionalMycroft Holmes28-Oct-20 13:07 
GeneralRe: The Best Free Database for real-time data storing and querying Pin
Member 1332584629-Oct-20 19:56
MemberMember 1332584629-Oct-20 19:56 
AnswerRe: The Best Free Database for real-time data storing and querying Pin
Gerry Schmitz30-Oct-20 9:40
mveGerry Schmitz30-Oct-20 9:40 
AnswerRe: The Best Free Database for real-time data storing and querying Pin
Eddy Vluggen1 hr 21mins ago
professionalEddy Vluggen1 hr 21mins ago 
QuestionDatabase ADO exception on adding new record Pin
Peter Mortier16-Oct-20 5:21
MemberPeter Mortier16-Oct-20 5: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 :

#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 5:53
mveRichard MacCutchan16-Oct-20 5:53 
AnswerRe: Database ADO exception on adding new record Pin
CHill6016-Oct-20 6:18
mveCHill6016-Oct-20 6:18 
GeneralRe: Database ADO exception on adding new record Pin
Peter Mortier19-Oct-20 2:58
MemberPeter Mortier19-Oct-20 2:58 
AnswerRe: Database ADO exception on adding new record Pin
Peter Mortier19-Oct-20 3:00
MemberPeter Mortier19-Oct-20 3:00 
GeneralRe: Database ADO exception on adding new record Pin
Victor Nijegorodov19-Oct-20 8:07
MemberVictor Nijegorodov19-Oct-20 8:07 
GeneralRe: Database ADO exception on adding new record Pin
Peter Mortier20-Oct-20 9:40
MemberPeter Mortier20-Oct-20 9:40 
GeneralRe: Database ADO exception on adding new record Pin
Victor Nijegorodov20-Oct-20 10:29
MemberVictor Nijegorodov20-Oct-20 10:29 
QuestionDatabase design and custom query for this use case ? Pin
karengsh14-Oct-20 0:17
Memberkarengsh14-Oct-20 0:17 
QuestionShould I store files in a database? Pin
Member 1260015012-Oct-20 23:37
MemberMember 1260015012-Oct-20 23:37 
AnswerRe: Should I store files in a database? Pin
Richard Deeming12-Oct-20 23:54
mveRichard Deeming12-Oct-20 23:54 
QuestionMYSQL Pin
Member 147129666-Oct-20 11:21
MemberMember 147129666-Oct-20 11:21 
AnswerRe: MYSQL Pin
ZurdoDev6-Oct-20 11:34
professionalZurdoDev6-Oct-20 11:34 
QuestionDatabase scripts version control process/strategy? Pin
Member 1363071429-Sep-20 7:06
MemberMember 1363071429-Sep-20 7:06 
AnswerRe: Database scripts version control process/strategy? Pin
David Mujica29-Sep-20 8:48
MemberDavid Mujica29-Sep-20 8:48 
AnswerRe: Database scripts version control process/strategy? Pin
ZurdoDev29-Sep-20 10:05
professionalZurdoDev29-Sep-20 10:05 
QuestionSimple Database design Pin
fdanos23-Sep-20 21:23
professionalfdanos23-Sep-20 21:23 
AnswerRe: Simple Database design Pin
Victor Nijegorodov23-Sep-20 21:54
MemberVictor Nijegorodov23-Sep-20 21: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.