cannot convert parameter 1 from 'QVariant' to 'VARIANT'
hi, why i have this error? there's my code:
Code:
ao.setControl("geometry.geometryenvironment");
IGeometryEnvironmentPtr ipGeoEnviron(CLSID_GeometryEnvironment);
IGeometryFactory2Ptr ipGeomFact(ipGeoEnviron);
ao.queryInterface(IID_IGeometryFactory2,(void**)&ipGeomFact);
IGeometryPtr ipGeom;
if (ipGeomFact){
long bytesRead;
if (ipGeomFact->CreateGeometryFromWkbVariant(value, &ipGeom, &bytesRead)))
}
VARIANT type is supported COM datataype, but as i understand it's supported only with calling methods using dynamicCall, i cant use dynamicCall because there's parameters of unsupported datatypes in CreateGeometryFromWkbVariant function:
Code:
HRESULT CreateGeometryFromWkbVariant(
VARIANT wkb,
IGeometry** outGeometry,
long* numBytesRead
);
so maybe i need to convert QVariant to VARIANT, but how?
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
What does the value really contain?
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
it's a value of a field from database, it's a QByteArray type, and VARIANT for CreateGeometryFromWkbVariant needs dataTypeEnum == adVarBinary
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
and the database field is a blob type... does QODBC support it?
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
So it's probably safest to convert it to const char * using toByteArray() and then constData() and then convert it to the VARIANT type.
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
yes, i'v tried it but, hr = ipGeomFact->CreateGeometryFromWkbVariant(value, &ipGeom, &bytesRead)) gives negative result
i've found another problem: VARIANT must be an array of usigned int type. toByteArray() gives an array of bytes which i must somehow convert to uint, and then make char* containing uint's?
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
that strange! i have an arrays in the field from msaccess db using QODBC of size 32 indexes bigger then from the same filds using ado and mfc, and the values of the arrays equals correspondingly only at the some first indexes.
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
If you have const char *, you can then cast it to unsigned int*.
Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'
yeap, i'v casted it to byte - unsigned char. thats no problem.
the problem is that recieved data from blob field from database is incorrect, precisley it is correct only in some bytes of bytes array. the size of the recivied array is also incorrect.