Click here to Skip to main content
16,017,899 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CreateProcess and Redirecting output Pin
Dave_8-Aug-02 4:33
Dave_8-Aug-02 4:33 
GeneralSetting height in CComboBox dropdown list Pin
Poul Haahr Klemmensen8-Aug-02 2:29
Poul Haahr Klemmensen8-Aug-02 2:29 
GeneralRe: Setting height in CComboBox dropdown list Pin
Alberto Giannetto8-Aug-02 2:41
Alberto Giannetto8-Aug-02 2:41 
GeneralRe: Setting height in CComboBox dropdown list Pin
Poul Haahr Klemmensen8-Aug-02 2:45
Poul Haahr Klemmensen8-Aug-02 2:45 
GeneralMultiline Tray Tooltip Pin
Alberto Giannetto8-Aug-02 1:37
Alberto Giannetto8-Aug-02 1:37 
GeneralRe: Multiline Tray Tooltip Pin
Ravi Bhavnani8-Aug-02 3:02
professionalRavi Bhavnani8-Aug-02 3:02 
GeneralRe: Multiline Tray Tooltip Pin
Alberto Giannetto8-Aug-02 3:52
Alberto Giannetto8-Aug-02 3:52 
GeneralAppendChunk bombs Pin
nss8-Aug-02 1:24
nss8-Aug-02 1:24 
I am trying to put a blob into an access database into a field of type OLE OBJECT (hope its the right one, tried text as well just in case). I get the crash at AppendChunk:

// Function which creates a safe array 

 void BlobToVariant(VARIANT &varArray)
{
	      BYTE *pByte;
	
	      FILE* pFile ;


	        long size;

	
		pFile =	fopen("C:\\Windows\\rhododendron.bmp", "rb");    		
		if(pFile == 0) // open failed ?
		{
			size = 0;

			return;
		}

	
		
		fseek(pFile, 0, SEEK_END);

		int fileSize = ftell(pFile);

		fseek(pFile, 0, SEEK_SET);



		if (size < fileSize)
		{
			size = fileSize;

			fclose(pFile);

			return;
		}
		

			
		size = fileSize;

		char *pImage;

		fread(pImage, size, 1, pFile);

		pImage[size] = 0; // Put a 0 char at the end

		fclose(pFile);

		CString CImage(pImage);



		SAFEARRAY FAR* psa;
		SAFEARRAYBOUND rgsabound[1];
		rgsabound[0].lLbound = 0;	
		rgsabound[0].cElements = CImage.GetLength() * sizeof(TCHAR) + sizeof(TCHAR);

		// create a single dimensional byte array
		psa = SafeArrayCreate(VT_I1, 1, rgsabound);
			
		// set the data of the array with data in the edit box
		if(SafeArrayAccessData(psa,(void **)&pByte) == NOERROR)
		memcpy((LPVOID)pByte,(LPVOID)CImage.GetBuffer(CImage.GetLength()),CImage.GetLength()+1);
		SafeArrayUnaccessData(psa);

		varArray.vt = VT_ARRAY | VT_UI1;
		varArray.parray = psa;

}



void DbClass::AddNewRecord(char* key1, char* value1)

{


		VARIANT varBLOB;

		BlobToVariant(varBLOB);

		m_pRecordset->AddNew();
		m_pRecordset->Fields->Item[0L]->AppendChunk(varBLOB);
		m_pRecordset->Update();

		VariantClear(&varBLOB);

		// Move to the last row ,as the row will be added at the end
		m_pRecordset->MoveLast();



Any ideas why?
Thanks,
ns
GeneralRe: AppendChunk bombs Pin
Ravi Bhavnani8-Aug-02 3:00
professionalRavi Bhavnani8-Aug-02 3:00 
GeneralRe: AppendChunk bombs Pin
nss8-Aug-02 5:08
nss8-Aug-02 5:08 
GeneralRe: AppendChunk bombs Pin
Ravi Bhavnani8-Aug-02 5:43
professionalRavi Bhavnani8-Aug-02 5:43 
GeneralRe: AppendChunk bombs Pin
nss8-Aug-02 7:08
nss8-Aug-02 7:08 
GeneralRe: AppendChunk bombs Pin
Ravi Bhavnani8-Aug-02 11:43
professionalRavi Bhavnani8-Aug-02 11:43 
GeneralRe: AppendChunk bombs Pin
Joel Lucsy8-Aug-02 6:11
Joel Lucsy8-Aug-02 6:11 
GeneralRe: AppendChunk bombs Pin
nss8-Aug-02 7:18
nss8-Aug-02 7:18 
GeneralRe: AppendChunk bombs Pin
nss8-Aug-02 7:40
nss8-Aug-02 7:40 
GeneralRe: AppendChunk bombs Pin
Joel Lucsy8-Aug-02 12:54
Joel Lucsy8-Aug-02 12:54 
GeneralHmmmm Pin
nss8-Aug-02 14:22
nss8-Aug-02 14:22 
GeneralSimple parameter return question (strings) Pin
-Dy8-Aug-02 1:12
-Dy8-Aug-02 1:12 
GeneralRe: Simple parameter return question (strings) Pin
8-Aug-02 1:32
suss8-Aug-02 1:32 
GeneralRe: Simple parameter return question (strings) Pin
Tomasz Sowinski8-Aug-02 1:32
Tomasz Sowinski8-Aug-02 1:32 
GeneralRe: Simple parameter return question (strings) Pin
Rutger Ellen8-Aug-02 1:48
Rutger Ellen8-Aug-02 1:48 
GeneralHELP ME........... Pin
Anonymous8-Aug-02 0:30
Anonymous8-Aug-02 0:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.