hello all, I'm now developing with MySQL and VC. And I have a question with the field 
which type is TEXT. I cann't insert the value with AppendChunk. Here is part of my 
code. 
        
        HRESULT hr;
        _RecordsetPtr pRS;
        _bstr_t G_CONNECTSTRING = 
                L"Persist Security Info=True;User ID=root;Data Source=NetVision;"\
                L"Mode=ReadWrite";
        hr = pRS.CreateInstance(__uuidof(Recordset));
        hr = pRS->Open(L"tb_Channel", G_CONNECTSTRING, 
                adOpenDynamic, adLockOptimistic, adCmdTable);
        VARIANT varTemp;
        VARIANT varBLOB;
        BYTE *pByte;
        
        try {
                SAFEARRAY FAR* psa;
                SAFEARRAYBOUND rgsabound[1];
                rgsabound[0].lLbound = 0;       
                rgsabound[0].cElements = m_strCScript.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)m_strCScript.GetBuffer(m_strCScript.GetLength()),m_strCScript.GetLength()+1);
                SafeArrayUnaccessData(psa);
        
                varBLOB.vt = VT_ARRAY | VT_UI1;
                varBLOB.parray = psa;
        
                pRS->Fields->Item[0L]->AppendChunk(varBLOB); // Field[0] is TEXT
                pRS->Update();
        }
        catch(_com_error &e) { // When AppendChunk is called, it reports the error:
                // Any failure in adding a new column cancel the update
                pRS->CancelUpdate();
                _bstr_t bstrSource(e.Source()); // Microsoft OLE DB Prvider for ODBC 
Drivers
                _bstr_t bstrDescription(e.Description()); // Invalid string or buffer 
length
                CString str;
                str.Format("\tCode = %08lx", e.Error());
                str += " Msg: ";        str += e.ErrorMessage();
                str += " Source: "; str += bstrSource;
                str += " Description: "; str += bstrDescription;
                AfxMessageBox(str);
        }


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to