ADO向ACCESS数据库插入数据问题,救急
m_Price是float型
m_Month是ctime型
其它是cstring型
错误提示:弹出错误对话框,×××.exe-应用程序错误,………………该内存不能为"read"
高手急救~~~~到底应该如何写
C/C++ code:
void CDailyAccountDlg::OnAdd()
{
UpdateData();
CString sql;
CoInitialize(NULL);
_ConnectionPtr pCon(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
try
{
pCon->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dailyAccount.mdb", "", "", adConnectUnspecified);
try
{
sql.Format("insert into daily(category,event,price,describe,date)values('%s','%s','%d','%s',#%s#)",csg_Category,csg_Event,m_Price,m_Desc,m_Month);
pRst->Open((_bstr_t)sql, _variant_t((IDispatch*)pCon), adOpenDynamic, adLockUnspecified, adCmdText);
}
catch(_com_error e)
{
AfxMessageBox("数据插入失败!");
}
}
catch(_com_error e)
{
AfxMessageBox("数据库连接失败!");
}
pRst->Close();
pCon->Close();
pRst.Release();
pCon.Release();
CoUninitialize();
}
你catch的时候就不能把错误信息显示出来吗?
C/C++ code
Code highlighting pro
相关问答:
_RecordsetPtr CMyAdo::SelectRecord(string &where, string &tablename,string &field, int way )
{
int ret = 0;
_RecordsetPtr pset;
CString sql;
& ......
ACCESS数据库中有一个tablename表,设计如下
编号,书名,作者,出版时间,出版社,ISBN,目录,简介
其中除“编号”为自动编号外,其它都为“备注”
其中"编号"维一,在“ISBN”中有的为空值, ......
我的一个access数据库中的photo字段中的内容是这样的:
|/UpFiles/Picture/admin/200910162300187612.jpg|/UpFiles/Picture/admin/200910162300187612.jpg||||/UpFiles/Picture/admin/200910162300187612.jp ......
请各位指点下:程序代码如下mingchen = "C:\文件路径\"
cat = New ADOX.Catalog
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & min ......
麻烦各位帮忙看看啊
代码如下:
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
pConn->ConnectionString="Provider ......