Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi

I have a simple task to transfer data from multiple tables in a MySql database into a single table.

I am using MFC for the task (simply because I haven't programmed in C# or C++ for about 5 years :( )

I need to jog my memory on Variable and strings etc so could someone help me with the following question.

I am using CRecordSet -> GetFieldValue(). Now this is fine for my text fields etc, but when it comes to a BLOB, or MEDIUMTEXT I'm struggling with an error.

MIDL
CString sProdName;
sections.Open(CRecordset::snapshot,SqlString);
sections.GetFieldValue(_T("Section text"),sProdName);


Should I be creating another type of variable to read this information in ? I don't need to do anything with it apart from write it straight back out.

Thanks.
Austin.
Posted

Thanks for the reply.

Worked out the solution myself, doesn't seem to be any clear samples about.

CDBVariant sVariant;
CString sProdName;
sections.Open(CRecordset::snapshot,SqlString);
sections.GetFieldValue(_T("Section text"),sVariant);
if (sVariant.dwtype == DBVT_ASTRING)
    sProdName=(CString)*sVariant.m_pstringA;


Not the greatest solution either, due to the age and lack of support for C++ MFC nowadays, I moved to C#

 char []desc=null;
 char []test=null;
long len = 
DbReader.GetChars(count, 0, test, 0, 65536);     //I know this field will not contain more than 65536 chars, so get the actual length;
DbReader.GetChars(count, 0, desc, 0, (int)len); // now I know the length, get it as chars
thedesc = new String(desc, 0, (int)len); // put it into a new String class from position 0 to len



Hope this helps someone out :)
 
Share this answer
 
you need to read the data with the correct function/flags. Cant you find a sample?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900