c# - Convert ADODB::Recordset^ to _RecordsetPtr -


i'm using c# dll inside in c++/cli wrapper. dll returning adodb::recordset^ object, need wrapper return _recordsetptr object. how can convert between two?

here's have far. problem i'm running in after last line of for-loop, function skips return statement , ends. doesn't continue looping, , doesn't hit "object^ rows = . . ." line.

_recordsetptr traserinterface::getdistributorrecordset() {     adodb::recordset^ recordset = traserwrapper::instance->traserinterface->distributorrecordset;     adodb::fields^ fields = ((adodb::recordsetclass^)recordset)->default;     hresult hr;     _recordsetptr recordsetptr("adodb.recordset");     (int = 0; < fields->count; i++)     {         adodb::field^ field = fields[i];         string^ fieldname = field->name;         _bstr_t bstrname = marshalstring(fieldname).c_str();         int type = (int)field->type;         int definedsize = field->definedsize;         int fieldattrib = field->attributes;         hr = recordsetptr->fields->append(bstrname, (datatypeenum)type, definedsize, (fieldattributeenum)fieldattrib);     }     object^ rows = recordset->getrows((int)adodb::getrowsoptionenum::adgetrowsrest, (object^)adodb::bookmarkenum::adbookmarkfirst, (object^)fields);     // loop through rows , populate recordsetptr . . .     return recordsetptr; } 

thanks hans passant, able find solution:

_recordsetptr traserinterface::getdistributorrecordset() {     adodb::recordset^ recordset = traserwrapper::instance->traserinterface->distributorrecordset);     intptr recordsetintptr = marshal::getiunknownforobject(recordset);     iunknown* unknown = (iunknown*)(void*)recordsetintptr;     _recordsetptr recordsetptr(unknown);     return recordsetptr; } 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -