一)
如果我用这样做可以增加,没问题
_variant_t vt("hello");
m_pRecordset->PutCollect(_variant_t(index), vt);二)
如果这么做就插不进去,
CString value;
value = "hello"; //或是value.Format("hello");
vt.vt = value.IsEmpty() ? VT_NULL : VT_BSTR;
vt.bstrVal = value.AllocSysString();
m_pRecordset->PutCollect(_variant_t(index), vt);我想问题是出在_variant_t对象的构造上,我不知道这两种方法有什么区别?大家帮帮我,多谢了!另外:三)
const char* pszText = "hello";
_variant_t vt(pszText);
_pRecordset->PutCollect(_variant_t(index), vt);这样做也没问题,但是当我把"hello"字符串通过函数参数传进去,又不行了?
比如四)
void AddRecord(long index, const char* pszText)
{
_variant_t vt(pszText);
_pRecordset->PutCollect(_variant_t(index), vt);
}多谢了!
如果我用这样做可以增加,没问题
_variant_t vt("hello");
m_pRecordset->PutCollect(_variant_t(index), vt);二)
如果这么做就插不进去,
CString value;
value = "hello"; //或是value.Format("hello");
vt.vt = value.IsEmpty() ? VT_NULL : VT_BSTR;
vt.bstrVal = value.AllocSysString();
m_pRecordset->PutCollect(_variant_t(index), vt);我想问题是出在_variant_t对象的构造上,我不知道这两种方法有什么区别?大家帮帮我,多谢了!另外:三)
const char* pszText = "hello";
_variant_t vt(pszText);
_pRecordset->PutCollect(_variant_t(index), vt);这样做也没问题,但是当我把"hello"字符串通过函数参数传进去,又不行了?
比如四)
void AddRecord(long index, const char* pszText)
{
_variant_t vt(pszText);
_pRecordset->PutCollect(_variant_t(index), vt);
}多谢了!
解决方案 »
- 工程设不了断点怎么解决?
- postmessage响应时间问题
- (winsdk)有没有什么办法以可绘制出和系统完全一致的控件(如滚动条),而不是创建窗口.谢谢.
- unicode编码的程序如何输出ansi编码的文本
- 我遇到了一个难的,*.DLL文件如何打开呢?用哪种编辑工具可编辑?
- 用ado访问数据库为什么,数据库占用内存越来越高
- 为大海啸受灾的人们, 散分!!!
- 简单问题,但是一下午都没解决!100分求助!
- 请问:如何用VC自己做一个SQL Server的“服务管理器”?其实就是做一个可以控制SQL Server服务器启动、暂停、停止的程序?谢谢!
- *********如何访问access中的日期/时间类型的字段?????????????
- 一个空间的盒子和一条直线判断是否相交有好方法吗?
- 一万元买源代码
vt.type = VT_BSTR
你直接做_variant_t vt("hello")时,它的构造函数会给你做这个
但是你直接vt.bstrVal = value.AllocSysString(),那么它的数据类型没有被设置
仍然是初始值
vt.bstrVal = value.AllocSysString();
m_pRecordset->PutCollect(_variant_t(index), vt);
都不行;而且value是不空的,他的内容为"hello"啊
再insert into 就可以了。
就第二个没有用过void AddRecord(long index, const char* pszText)
{
_variant_t vt(pszText);
_pRecordset->PutCollect(_variant_t(index), vt);
}
我是写成_pRecordset->PutCollect(_variant_t((long)index), _variant_t(pszText));
Provider=Microsoft.Jet.OLEDB.3.51; 而我用的是
Provider=Microsoft.Jet.OLEDB.4.0;