设为首页 收藏本站

MCBANG

 找回密码
 立即注册

QQ登录

只需一步,快速开始

快捷导航
搜索
查看: 12483|回复: 0

[转载] 读取 Clob 字段的数据

[复制链接]
发表于 2012-12-8 16:05:05 |显示全部楼层
cpp代码
  1. using namespace System;
  2. using namespace System::Data;
  3. using namespace System::IO;
  4. using namespace System::Data::OleDb;

  5. void main()
  6. {
  7. OleDbConnection myConnection = nullptr;
  8. myConnection = gcnew OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Music.mdb");
  9. myConnection->Open();
  10. OleDbCommand myCommand = gcnew OleDbCommand("SELECT FileName, MP3 FROM MP3Storage", myConnection);
  11. OleDbDataReader myReader = myCommand->ExecuteReader(CommandBehavior::SequentialAccess);
  12. array<unsigned char> buffer = gcnew array<unsigned char>(65536);
  13. while ( myReader->Read() ){
  14. String fileName = safe_cast<String>(myReader->GetValue(0));
  15. FileStream fileStream = gcnew FileStream(fileName, FileMode::Create);
  16. long long bytesRead, position = 0;
  17. while ( bytesRead = myReader->GetBytes(1, position, buffer,0, buffer->Length) ){
  18. fileStream->Write(buffer, 0, (int)bytesRead);
  19. position += bytesRead;
  20. }
  21. Console::WriteLine("{0} bytes writte to {1} file",position, fileName);
  22. fileStream->Close();
  23. }
  24. myConnection->Close();
  25. }
复制代码
  大家好,我是Timiky,一个学习中的程序猿,,喜欢程序的关注我哦!
欢迎来到网络尖刀新生代网络安全综合媒体! 请记住我们的网址 Www.Mcbang.Com [官方Q群:55420062]
您需要登录后才可以回帖 登录 | 立即注册

Archiver|知娱 ( 京ICP备14006288号-3  

GMT+8, 2020-4-2 04:26 , Processed in 0.157233 second(s), 31 queries .

请勿发布违反中华人民共和国法律法规的言论
郑重声明:本站会员观点不代表【网络尖刀】论坛官方立场。

Copyright© 2006-2016 IjianDao.Com All rights reserved. 知娱 版权所有

回顶部