首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Access >

对话框使用ODBC访问access数据库,该怎么处理

2012-02-13 
对话框使用ODBC访问access数据库在对话框中使用ODBC访问ACCESS数据库, 连接\查询都正常, 但是添加记录, 编

对话框使用ODBC访问access数据库
在对话框中使用ODBC访问ACCESS数据库, 连接\查询都正常, 但是添加记录, 编辑记录等操作在Update时, 返回都是失败! 
增加记录部分代码如下:
UpdateData(TRUE);

CString ID = this->m_ID;
CString Name = this->m_Name;
CString InTime = this->m_InTime;
CString OutTime = this->m_OutTime;
CString Department = this->m_Department;


this->m_RecordsetEmployee.AddNew();

this->m_RecordsetEmployee.m_ID = ID;
this->m_RecordsetEmployee.m_NAME = Name;
this->m_RecordsetEmployee.m_INTIME = InTime;
this->m_RecordsetEmployee.m_OUTTIME = OutTime;
this->m_RecordsetEmployee.m_DEPARTMENT = Department;

if( 0 == this->m_RecordsetEmployee.Update() )
{
::AfxMessageBox( "Fail to add new record!" );
}
this->m_RecordsetEmployee.Requery();

[解决办法]
为什么不用ADO连接MDB
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\1.mdb
[解决办法]
调试中看一下你的这些变量的内容是什么?
ID;Name;InTime;OutTime;Department;

估计有为空的,或者数据类型不符合的。

热点排行