// 连接数据库
_ConnectionPtr m_pConnection;
void ConnDataBase()
{
try
{
CoInitialize(NULL); //对连接进行初始化
m_pConnection.CreateInstance(__uuidof(Connection));
// Mode=Share Deny Read|Share Deny Write
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\去权限\\ET2.6个人版刘兰冰1\\et.mdb;Jet OLEDB:DataBase Password= ;Mode=Share Deny Read|Share Deny Write","","",0);
}
catch(_com_error e)
{
// 错误信息
MessageBox(0,e.Description(),0,0);
//e.Description();
return ;
}
}
// 执行SQL语句
void CommandExeSQL()
{
_RecordsetPtr rs;
rs.CreateInstance(__uuidof( Recordset )); //创建实例
char sql[500]= "DELETE FROM list WHERE id=837";
OutputDebugStringW(L"是要执行这里吗");
rs->Open(_com_util::ConvertStringToBSTR(sql),((_ConnectionPtr)GetConnectionBaseAdd()).GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
OutputDebugStringW(L"这里的问题吗");
rs->Close();
}
Access数据库的基本操作
最新推荐文章于 2024-09-27 14:32:16 发布