Connect to Pervasive SQL & Delete a record using CRecordset::Delete() Function - Error "Invalid argument type"


 

hi there,
i'm writting small program in visual c++ (mfc) can interact pervasive sql database.
i connect sql database using odbc link. i have been able run  standard sql queries
using crecordset to retrieve records tables , display them on listcntrl etc 
with no problem. example (so undersatnd better trying do)

///////////////////////////////////////////////////////

crecordset rs(&cdatabase);

cstring cs;

cs = "select stockcode stock stockcode= '               1'";

if (rs.open(crecordset::forwardonly, cs))

{

    for (int = 0; < rs.getodbcfieldcount(); i++)

    {

        rs.getfieldvalue(i, cstring);
    }
}

////////////////////////////////////////////////////////////
 
one of tasks able delete dertain records table (based on criteria, ex: stock code = 10)

i can't seem code work, have read msdn , tried implement that. "invalid argument value" error.
following is code 

//////////////////////////////////////////////////

crecordset rset(&cdatabase);

cstring cs;

cs = "select stockcode from stock stockcode = '              10'";   // stockcode has padding

cstring cstring;

if (rset.open(crecordset::forwardonly, cs, 0))

{

    if (rset.canupdate())

    {

        rset.delete();

    }
}

//////////////////////////////////////////////////////////////////

my undestanding that, 'cs' should return record matching stockcode (10).
then if use rset.delete() function, should delete the current record. 

as far can see, the problem line rset.delete(). doesn't it. 
i steped through the coding and found gets line 249 in 'wincore.cpp' file.


// tried following statement, instead of select tried delete  
// cs = "delete stock stockcode stockcode = '              10'";
// still no good.

any appriciated..

hi jay,

 

this forum microsoft sql server data access - looks issue you're having application code - may want post inquiry in appropriate msdn forum.

 



SQL Server  >  SQL Server Data Access



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........