我有一个结构体
typedef struct _tagDATA
{
INT64 nVal;
double dCurVal;
BOOL bIsChecked;
}DATA, *PDATA;
程序中结构体变量的个数是动态的,我想将这些变量保存在数据库的一个BLOB属性中,请问该如何保存和读取呢?谢谢!
例如我有DATA[10]将其插入到数据库中。
typedef struct _tagDATA
{
INT64 nVal;
double dCurVal;
BOOL bIsChecked;
}DATA, *PDATA;
程序中结构体变量的个数是动态的,我想将这些变量保存在数据库的一个BLOB属性中,请问该如何保存和读取呢?谢谢!
例如我有DATA[10]将其插入到数据库中。
CoInitialize(NULL);//初始化COM库
_ConnectionPtr pConn(__uuidof(Connection));//实例化一个connection对象pConn
_RecordsetPtr pRst(__uuidof(Recordset)); //实例化一个Recordset对象pRst
//连接字符串说明:Provider表示驱动引擎;User ID表示用户名;Password表示口令;Initial Catalog表示数据库名
pConn->ConnectionString=
"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=xx;Password=;Data Source=(local)";
try
{
pConn->Open("","","",adConnectUnspecified);
pRst=pConn->Execute("(_bstr_t)sql语句",NULL,adCmdText);
while(!pRst->rsEOF)
{
..(_bstr_t)pRst->GetCollect("列名");
pRst->MoveNext();
}
}
catch(_com_error e)
{
MessageBox(e.Description());//输出异常原因。
return;
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();//释放COM库
谢谢
我用的是mysql语句,不知道这个是不是...