MFC-CRecordSet-MySQL-BLOB [英] MFC - CRecordSet - MySQL - BLOB

查看:109
本文介绍了MFC-CRecordSet-MySQL-BLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个简单的任务,可以将数据从MySql数据库中的多个表转移到单个表中.

我正在使用MFC进行这项工作(这是因为大约5年没有使用C#或C ++编程了:()

我需要在变量和字符串等上慢跑我的记忆,所以有人可以帮助我解决以下问题.

我正在使用CRecordSet-> GetFieldValue().现在,这对于我的文本字段等来说很好,但是当涉及到BLOB或MEDIUMTEXT时,我正在为错误而苦苦挣扎.

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.

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.

推荐答案

感谢回复.

我自己制定了解决方案,似乎没有任何清晰的示例.

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;



也不是最好的解决方案,由于当今的时代和缺乏对C ++ MFC的支持,我搬到了C#



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 :)


您需要使用正确的功能/标志读取数据.无法找到样品吗?
you need to read the data with the correct function/flags. Cant you find a sample?


这篇关于MFC-CRecordSet-MySQL-BLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆