统计 |
blog名称:人在旅途 日志总数:175 评论数量:505 留言数量:13 访问次数:1661400 建立时间:2005年12月7日 |
生命是过客,人在旅途。奶奶是信基督教的,没啥文化,却养育了四子二女,还带过九个孙辈。老人家对生命的看法就是“人都是客人,迟早要回去的。”就以《人在旅途》来纪念她。

« | July 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | |
|
公告 |
本人上传的源程序中可能引用或使用了第三方的库或程序,也可能是修改了第三方的例程甚至是源程序.所以本人上传的源程序禁止在以单纯学习为目的的任何以外场合使用,不然如果引起任何版权问题,本人不负任何责任. | |

|
本站首页 管理页面 写新日志 退出
调整中...
[微软技术开发]A new way to use ADO in VC++ |
人在旅途 发表于 2006/1/22 10:13:08 |
Techniques for Using ADO in C++ Applications
There are a couple of ways to use ADO in your C++ code. You can use the ADO header files and import library from the OLE DB SDK. You include the ADO header files (adoid.h and adoint.h) in your source and add the ADO import library adoid.lib to your linker input. This enables you to create instances of the ADO objects and access their member functions. Using this method, the code to connect to a data source and create a Command object could look something like Listing 4.1. The code in Listing 4.1 doesn't check return values for the sake of code brevity. This is a code snippet only and will not compile as shown.
Listing 4.1. Using ADO via the OLE DB SDK
1: ADOConnection* piConnection;
2: ADOCommand* piCommand;
3:
4: CoCreateInstance(CLSID_CADOConnection, NULL,CLSCTX_INPROC_SERVER,
IID_IADOConnection, (LPVOID *)&piConnection);
5:
6: CoCreateInstance(CLSID_CADOCommand, NULL,CLSCTX_INPROC_SERVER,
IID_IADOCommand, (LPVOID*)&piCommand);
7:
8: piConnection->Open(L"MyDSN", L"sa", L"bodacious");
9:
10: piCommand->putref_ActiveConnection(piConnection);
Lines 1 and 2 declare pointers to two ADO COM interfaces. Lines 4 and 6 call CoCreateInstance to create instances of the ADO interfaces and assign the pointers to them. (You will learn more about CoCreateInstance and COM interfaces on Day 9, "Understanding COM.") Line 8 uses the Open function of the ADO Connection object to open a connection with an ODBC data source called MyDSN. It uses a username of sa (system administrator) and a password of bodacious. Line 10 calls the ADO Command object's putref_ActiveConnection function to tell it to use the connection that was opened in line 8. Later in your program you will need to call the Release function on piConnection and piCommand to free those objects.
|
阅读全文(1998) | 回复(0) | 编辑 | 精华 |
|