今天在研究VC++ 使用 ADO 讀取MS SQKSERVER 數據庫時, 發(fā)現:
string ansi字符串
wstring unicode字符串
_bstr_t com字符串
之間的轉換關系,示例如下:
// ex_02_wstring_cv_string.cpp : 定義控制臺應用程序的入口點。
//
#include "stdafx.h"
#include "string"
#include "icrsint.h"
#include "comutil.h"
using namespace std;
#import "C:\\Program Files\\Common Files\\System\\ADO\\msado15.dll" no_namespace rename("EOF", "EndOfFile")
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
wstring ws1,ws2;
ws2 = L"春如舊,人空瘦,淚痕紅浥鮫綃透。桃花落,閑池閣,山盟雖在,錦書難托。莫、莫、莫。";