Hello erw2,

This is how I do it.


        HRESULT hr = Compile("INSERT OR IGNORE INTO Files_V1"
        "("
                "FileOrder,"
                "Filename,"     
                "Length,"
                "Signature," 
                "Date,"
                "Topic, "       
                "Title, "       
                "Chapter,"      
                "User1,"        
                "User2,"        
                "File"  
        ") VALUES (?,?,?,?,?,?,?,?,?,?,?);");


        string_t sFilename = pszFilename;
        size_t nFound = sFilename.find_last_of('\\');
        if( nFound < sFilename.size())
        {
                sFilename.erase(sFilename.begin(),sFilename.begin() + nFound+1);
        }
        //
        // Order
        //
        BindInteger(1,nIndex);
        //
        // Filename
        //
        BindText(2,sFilename.c_str());

        //
        // File Length
        //
        BindInteger(3,(size_t)nLength);

        //
        // File MD5
        //
        CMD5File::MD5File(pszFile,(size_t)nLength,pMD5);
        BindBlob(4,pMD5,MD5_DIGEST_LENGTH);
        
        //
        // Insertion Date
        //
        BindInteger(5,time(NULL));

        //
        //"Topic, "     
        //
        BindText(6,pszTopic);

        //
        //"Title, "     
        //
        BindText(7,pszTitle);

        //
        //"Chapter, "   
        //
        BindText(8,pszChapter);


        //
        //"User1,"      
        //
        BindText(9,pszUser);

        //
        //"User2,"      
        //
        BindText(10,"");

        //
        //"File"        
        //
        BindBlob(11,pszFile,(size_t)nLength);

        size_t nResults;
        HRESULT hr = Step(nResults);
        ResetBindings();
        if( FAILED(hr))
        {
                FreeError();
                assert(0);
                return(E_ABORT);
        }
        return(S_OK);   

The bind functions are just my wrappers over "sqlite3_bind_blob"

HRESULT
CDBSqLite3::BindBlob(size_t nColumn,const unsigned char* pData,size_t nLength)
{
        return(BindBlob(m_pVm,nColumn,pData,nLength));
}



HRESULT
CDBSqLite3::BindBlob(sqlite3_stmt* pVm,size_t nColumn,const unsigned char* 
pData,size_t nLength)
{
        int nCols = sqlite3_bind_parameter_count(pVm);
        if( nCols < nColumn )
        {
                assert(0);
                return(E_ABORT);
        }

    int nResults = sqlite3_bind_blob(pVm,nColumn,pData,nLength, SQLITE_STATIC);
        if( nResults != SQLITE_OK)
        {
                assert(0);
                return(E_ABORT);
        }
        return(S_OK);
}


I've just pasted a couple functions together here so, it's just an
example. It's not exactly compilable in this state.

C


        

Tuesday, December 6, 2005, 7:15:25 PM, you wrote:

eop> Hi all,
eop> so I have a (not) simple question.
eop> Is it possible to insert into blob field content of the file? How to =
eop> manage it in C++?

eop> Regards
eop> WojciechW



-- 
Best regards,
 Teg                            mailto:[EMAIL PROTECTED]

Reply via email to