How to access varbinary field
- From: "sky" <sky_hc@xxxxxxx>
- Date: Tue, 25 Dec 2007 12:52:50 +0800
hi all
The following is my code that access varbinary field(in SQL Server 2000) but
failed always
unsigned long data[3] = {101, 301, 505}; // for test
TCHAR *sql = _T("update A set F2 = @data where F1 = 1000");
pCmd->CommandText = sql;
pCmd->CommandType = adCmdText;
pCmd->CommandTimeout = 0;
_variant_t var;
// Create a SAFEARRAY.
SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, sizeof(data));
// Copy the data to the SAFEARRAY.
int *pData;
HRESULT hr = SafeArrayAccessData(psa, (void **)&pData);
memcpy(pData, data, sizeof(data));
SafeArrayUnaccessData(psa);
//Assign the Safe array to a variant.
var.vt = VT_ARRAY|VT_UI1;
var.parray = psa;
_ParameterPtr param = pCmd->CreateParameter(_T("@data"), adVarBinary,
adParamInput, sizeof(data), var);
pCmd->Parameters->Append(param);
pCmd->Execute(NULL, NULL, adCmdText);
SafeArrayDestroy(psa);
Any hint?
TIA
sky
.
- Follow-Ups:
- Re: How to access varbinary field
- From: Sylvain Lafontaine
- Re: How to access varbinary field
- Prev by Date: Re: Regarding Order By Clause In Stored Procedure
- Next by Date: Re: How to access varbinary field
- Previous by thread: Re: Regarding Order By Clause In Stored Procedure
- Next by thread: Re: How to access varbinary field
- Index(es):
Relevant Pages
|
|