Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in INSERT INTO 1

Status
Not open for further replies.

PavelGur

Programmer
Sep 21, 2001
75
I got this error on Recordset AddNew which I used many times before and have never had any prblems. I checked all values and column names and did not find any suspects. I also searched Web and did not find any meaningful answers. Here is the code:
Code:
pBTCH->AddNew();
   pBTCH->m_CurBatch;
   pBTCH->m_PolicyNum = iPolNum;
   pBTCH->m_CrntTime = tBatch;
   pBTCH->m_NumOfStocks = 1;
   pBTCH->m_PurAmount = floor(fPurAmount * 100 +.05) / 100;
   pBTCH->m_SellAmount = 0;
   pBTCH->m_CurAmount = floor(fCurAmount * 100 +.05) / 100;
   pBTCH->m_BtchClosed = false;
pBTCH->Update();
Any ideas?
Thank you, Pavel.
 
What does this do?
Code:
   pBTCH->m_CurBatch;
It is not a procedure call or an assignment. Is it really required or is there something missing from it?
 
Sorry, this was typo. Actual line is
pBTCH->m_CurBatch = tBatch;
with correct value in it. I've just checked it again and received the same error.
Thanks, Pavel.
 
I found the resolution and I want to share it with others because I've seen few questions on the Web related to this error.

The problem was that I was opening the Batch recordset to find all batches that were not closed. If I find one I was planning to update it. Otherwise I would add new one.
However in my case there were no any open batches. So though open statement did not give me any errors the INSERT statement generated by Recordset was "INSERT INTO BatchTable where Closed = false". This generated the above mentioned error. I found out this by stepping in Upcate() in Debug.

After I closed (if IsOpen) batch Recordset and opened it again without WHERE clause the Update worked.
Pavel.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top