怎样在VC6.0控制台上写SQL语句

oklizy 2007-08-25 09:10:49
怎样在VC6.0控制台上写SQL语句,请高手举个例子,我在自学数据库
...全文
162 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
oklizy 2007-10-05
  • 打赏
  • 举报
回复
谢谢了
zjexe 2007-08-26
  • 打赏
  • 举报
回复
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
int main(int argc, char* argv[])
{
printf("This sample shows you how to access BLOB via ADO and store it as file"
"The second field of the database is BLOB\n"
"If it works, it is writen by masterz,\n"
"otherwise I don't know who write it\n");
CoInitialize(NULL);
try
{
_ConnectionPtr pConn("ADODB.Connection");
_RecordsetPtr pRst("ADODB.Recordset");
_variant_t varBLOB;
pConn->Open(_bstr_t("Driver={Microsoft Access Driver (*.mdb)};DBQ=GetChunk.mdb"),"","",adConnectUnspecified);
pRst->Open(_bstr_t("BlobTable"),_variant_t((IDispatch *) pConn, true),
adOpenKeyset, adLockOptimistic, adCmdTable);
pRst->MoveFirst();
//long lDataLength = pRst->Fields->Item[1L]->ActualSize;
//varBLOB = pRst->Fields->Item[1L]->GetChunk(lDataLength);
_StreamPtr stream;
stream.CreateInstance("ADODB.Stream");
_variant_t varOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
stream->raw_Open(varOptional, adModeUnknown, adOpenStreamUnspecified,NULL,NULL);
stream->put_Type(adTypeBinary);
stream->Write(pRst->GetFields()->GetItem(_variant_t((long)1))->GetValue());
stream->SaveToFile("test.txt",adSaveCreateOverWrite);
printf("save stream to file finished\n");
stream->Close();
pRst->Close();
pConn->Close();
}
catch (_com_error &e)
{
printf("Description = '%s'\n", (char*) e.Description());
}
::CoUninitialize();
return 0;
}

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧