[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Newbie, ODBC, CRecordSet not adding new record on ONE WinXP Build 520 machine, however works on other machines, and ExecuteSQL always works

robdob2003

10/2/2005 4:01:00 PM

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();
}


2 Answers

Tim

10/2/2005 10:01:00 PM

0

What is the design of your table?
Please provide the SQL for creating the table.
How do you know it does not add the new record? Sounds like a dumb question,
but you may be putting the new record in one database, and looking for it in
another. This is why it is important to use one CDatabase object per
required database in an application...

What do you mean by this: "then the recordset addnew seems to work moving
forward".

- Tim

<robdob2003@yahoo.com> wrote in message
news:OSKp%23p2xFHA.2312@TK2MSFTNGP14.phx.gbl...
> 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();
> }
>


robdob2003

10/3/2005 1:21:00 AM

0

Hello,

everything works find on all the other machines, even the other winxp Build
520 machines,

I know the record is not added because if I query the table no record has
been added...
I am not putting the record in another database, and it also works
flawlessly on other machines...

What I mean by, "then the recordset addnew seems to work moving forward".

IS that if I first add a ONE record using:

CString cSQL;
cSQL.Format( "INSERT INTO Templates (TemplateName, TemplateID) VALUES
(''test write'', 9999)");
m_pdatabase->ExecuteSQL( cSQL );

afterwhich the following will also add records, but if I try and add a
record to a empty table CRecordset will not end up adding anything nor will
it return an error..., remember once again that this is ONLY on the ONE
machine, on the other machines it works fine.. Also I try to use ODBC
Trace from within the ODBC admin panal and for some reason, it does NOT log
CRecordset transactions i.e. the code below.. I''m not sure if this is
suppose to be the behavior...



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;











"Tim" <Tim@NoSpam> wrote in message
news:%23M2RHz5xFHA.612@TK2MSFTNGP10.phx.gbl...
> What is the design of your table?
> Please provide the SQL for creating the table.
> How do you know it does not add the new record? Sounds like a dumb
> question, but you may be putting the new record in one database, and
> looking for it in another. This is why it is important to use one
> CDatabase object per required database in an application...
>
> What do you mean by this: "then the recordset addnew seems to work moving
> forward".
>
> - Tim
>
> <robdob2003@yahoo.com> wrote in message
> news:OSKp%23p2xFHA.2312@TK2MSFTNGP14.phx.gbl...
>> 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();
>> }
>>
>
>