有的话,能不能给出一点参考???谢谢!!!
解决方案 »
- 子窗口中为什么不能响应OnMouseWheel ?
- VS2005头文件与cpp文件切换的快捷键
- vs2008下如何使用windows media player控件?
- 正则表达式解析
- BOOL CHtmlView::GetSource(CString& refString) 调用GetSource为什么错误?
- 在自定义的静态文本类里用OnTimer实现时间实时输出问题!
- 能不能把一个“模式对话框”临时转换成一个“无模式”对话框,尔后再转回来???
- 继续问:StretchBlt如何缩放位图?
- 请教:怎么在程序中改变窗口的宽度?谢谢!
- 关于断开网络连接
- 关于自动化传递参数的问题
- 求救!如何给application发一个消息?
VC98\SDK\DBMSG
例子如下:
// ADOSample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <objbase.h>
#include <oledb.h>
#include <atlbase.h>
#include <windows.h>
#include <comdef.h>#import "c:\\Program Files\\Common Files\\System\\ADO\\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#import "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll" void dump_com_error(_com_error &e)
{
printf("Error\n");
printf("\a\tCode = %08lx\n", e.Error());
printf("\a\tCode meaning = %s", e.ErrorMessage());
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf("\a\tSource = %s\n", (LPCSTR) bstrSource);
printf("\a\tDescription = %s\n", (LPCSTR) bstrDescription);
}
int main(int argc, char* argv[])
{
printf("Hello World!\n");
::CoInitialize(NULL);
try
{ _ConnectionPtr pCon=NULL;
_RecordsetPtr pRs=NULL;
pCon.CreateInstance(__uuidof(Connection));
pCon->Open("Export","dongsong","dongsong",adConnectUnspecified);
pRs.CreateInstance(__uuidof(Recordset));
pRs->CursorLocation=adUseClient;
pRs->Open("select name from sysobjects where type='u'",
_variant_t((IDispatch *) pCon, true),adOpenStatic, adLockReadOnly, adCmdUnknown);
while (!(pRs->EndOfFile))
{
printf("%s\n",(char*)_bstr_t(pRs->Fields->Item["name"]->Value));
pRs->MoveNext();
}
}catch (_com_error &e)
{
dump_com_error(e);
}
::CoUninitialize();
return 0;
}