2010-05-11 3 views

Répondre

0

Je trouve cet exemple:

while(!rst->EndOfFile) 
{ 
     int shotid = rst->Fields->Item["shot_id"]->Value; 
     int shotPoint = rst->Fields->Item["shot_num"]->Value; 
     int length = rst->Fields->Item["length"]->Value; 

    --- I initialized tha variant and copied the variant into local memory. After that I accessed the SafeArray. 
     VariantInit(&varBlob); 
     //varBlob = rst->Fields->Item["data"]->GetChunk((long) MAX_HYDRO_SIZE); 
     varBlob = rst->Fields->Item["data"]->GetValue(); 
     unsigned char* pData; 
     unsigned char data[MAX_HYDRO_SIZE]; 
     int blobLength; 

     if (varBlob.vt == (VT_ARRAY | VT_UI1)) 
     { 
         SafeArrayAccessData(varBlob.parray,(void **) &pData); 
       blobLength = varBlob.parray->rgsabound[0].cElements; 
       TRACE(" length %d : blobLength %d \n",length*4, blobLength); 
       if (length*4 > blobLength) 
        AfxMessageBox("Blob Short of Data"); 
       memcpy(&data,pData,blobLength); 
       SafeArrayUnaccessData(varBlob.parray); 
     } 
     else 
     AfxMessageBox("BLOB returned wrong type"); 

sur http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_21296032.html

+0

Merci Preet mais je ne pouvais pas utiliser le code comme je ne suis pas capable d'écrire le fichier dans la colonne varbinary (MAX) de la base de données la toute première place. Encore une fois merci beaucoup car vous essayez de m'aider. Passez une bonne journée. –

Questions connexes