主要是GetFieldValue问题,如果读取数字的话,他的类型就要定义为CDBVariant。但是我不知道这种类型以后如何赋值,如何与int类型的变量比较以及如何输出。请各位高手指教一下,如果有更好的读取数据库的函数也介绍一下,谢谢!!!!!!!
解决方案 »
- 新手求助!工具栏中的按钮是怎么响应的?
- 关于ODBC数据库的问题
- 在VC++6.0怎么设置一个x*x的窗体,窗体的大小怎么设置?
- 获取外部进程状态[很有难度]
- 我有一个日期格式的CString值,我要赋给一个CTime的变量,请问用什么方法转换最好?
- 静态联接库的问题!
- basicexcel读写大于7M文件的问题
- 高分请教asp的com组件调用问题
- 用C语言编写(最好是VC++),电脑上是USB蓝牙适配器,用这个来搜索周围蓝牙,并把搜索到的地址名字显示出来,并且可以配对
- MFC图像在内存的操作
- 9054的pci问题,驱动中没有进入中断处理流程,请高手指点?
- CDBVariant与CString 转换问题
m_boolVal Contains a value of type BOOL.
m_chVal Contains a value of type unsigned char.
m_iVal Contains a value of type short.
m_lVal Contains a value of type long.
m_fltVal Contains a value of type float.
m_dblVal Contains a value of type double.
m_pdate Contains a pointer to an object of type TIMESTAMP_STRUCT.
m_pstring Contains a pointer to an object of type CString.
m_pbinary Contains a pointer to an object of type CLongBinary
m_boolVal Contains a value of type BOOL.
m_chVal Contains a value of type unsigned char.
m_iVal Contains a value of type short.
m_lVal Contains a value of type long.
m_fltVal Contains a value of type float.
m_dblVal Contains a value of type double.
m_pdate Contains a pointer to an object of type TIMESTAMP_STRUCT.
m_pstring Contains a pointer to an object of type CString.
m_pbinary Contains a pointer to an object of type CLongBinary
AfxOleInit();///初始化COM库 HRESULT hr;
hr=m_pConnection.CreateInstance("ADODB.Connection");
if (FAILED(hr)) return FALSE;
try
{
hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=my.mdb","","",adModeUnknown);
}
catch (_com_error &e)
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
return FALSE;
}