如何从数据库中读取CLongBinary字段并将其写入CFile对象
How can I read a CLongBinary field from my database and write it into a CFile object?
im使用CRecordset从我的SQL Server获取数据。一个表存储一个二进制文件(pdf,odt,…)。我的VisualStudio将列映射到CLongBinary字段。
如何从CLongBinary字段读取并打开文件
im使用MFC的一些古代版本4.2,VisualStudio6.0
这样做。这只会给你一个想法。我还没有测试代码。
CLongBinary myfield ;
... retrive myfield from database here
BYTE *dataptr = (BYTE*)GlobalLock(myfield.m_hData) ;
// now dataptr points to your raw data, and myfield.m_dwDataLength is the length of that data
CString tempname = ... create temporary filename somewhere
CFile myfile ;
myfile.Open(tempfilename, CFile::modeCreate|CFile::modeWrite);
myfile.Write(dataptr, myfield.m_dwDataLength) ,
myfile.Close() ;
GlobalUnlock(myfield.m_hData) ;
ShellExecute(NULL, _T("open"), tempfilename, NULL, NULL, SW_SHOW) ;
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- CMake-按正确顺序将项目与C运行时对象文件链接
- 空基优化子对象的地址
- 将对象数组的引用传递给函数
- 你能重载对象变量名本身返回的内容吗
- C++使用整数的压缩数组初始化对象
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 将对象移动到std::shared_ptr
- 代理对象的常量正确性
- 提升 ASIO 无法识别计时器对象
- 将Ref对象作为类成员
- 将包含C样式数组的对象初始化为成员变量(C++)
- 如何返回一个类的两个对象相加的结果
- 使用std::函数映射对象方法
- 是否需要删除包含对象的"pair"?
- 如何在自删除后将对象设置为nullptr
- 迭代时从向量和内存中删除对象
- 构造对象的歧义
- 如何从数据库中读取CLongBinary字段并将其写入CFile对象