G
Guest
Hi,
I have a very puzzling problem, and am hoping someone can help. I have a
VC7.1++ VS2003, program which uses ODBC to connect to a SQLAnywhere 6.0
database. This program has been working without fail for many years,
however the problem that I am now running into is that on one WinXP machine
the CRecordset is not adding a new record, the really odd thing is that if
I first add one record to the table using the ExecuteSQL( insert into... ),
which always seems to work, then the recordset addnew seems to work moving
forward.
I've included a code sniplet below, any help would be very much apprecuated
as this is very frustrating...
/* This adds a records correctly*/
CString cSQL;
cSQL.Format( "INSERT INTO Templates (TemplateName, TemplateID) VALUES ('test
write', 9999)");
m_pdatabase->ExecuteSQL( cSQL );
/* this does NOT add a new record unless one already exists within the
table, nor does it throw an exception*/
try
{
CRecsetTemplates* pRST2 = new CRecsetTemplates( m_pdatabase );
pRST2->Open();
pRST2->AddNew();
pRST2->m_TemplateName = "TEST TEMPLATE!!!!";
pRST2->m_TemplateID = 9999;
pRST2->Update();
pRST2->Close();
delete pRST2;
}
catch(CDBException* e)
{
e->ReportError();
e->Delete();
}
I have a very puzzling problem, and am hoping someone can help. I have a
VC7.1++ VS2003, program which uses ODBC to connect to a SQLAnywhere 6.0
database. This program has been working without fail for many years,
however the problem that I am now running into is that on one WinXP machine
the CRecordset is not adding a new record, the really odd thing is that if
I first add one record to the table using the ExecuteSQL( insert into... ),
which always seems to work, then the recordset addnew seems to work moving
forward.
I've included a code sniplet below, any help would be very much apprecuated
as this is very frustrating...
/* This adds a records correctly*/
CString cSQL;
cSQL.Format( "INSERT INTO Templates (TemplateName, TemplateID) VALUES ('test
write', 9999)");
m_pdatabase->ExecuteSQL( cSQL );
/* this does NOT add a new record unless one already exists within the
table, nor does it throw an exception*/
try
{
CRecsetTemplates* pRST2 = new CRecsetTemplates( m_pdatabase );
pRST2->Open();
pRST2->AddNew();
pRST2->m_TemplateName = "TEST TEMPLATE!!!!";
pRST2->m_TemplateID = 9999;
pRST2->Update();
pRST2->Close();
delete pRST2;
}
catch(CDBException* e)
{
e->ReportError();
e->Delete();
}