比如
向table1中
CString strSql="INSERT table1 (field1,filed2) VALUES ('','')";
CDatabase m_DB;
m_DB.OpenEx("DSN=xxx;UID=sa;PWD=");
m_DB.ExecuteSQL(strSql);
向table1中
CString strSql="INSERT table1 (field1,filed2) VALUES ('','')";
CDatabase m_DB;
m_DB.OpenEx("DSN=xxx;UID=sa;PWD=");
m_DB.ExecuteSQL(strSql);
其实我是知道为什么我的这种最简单的方法(有点死板)以前好使,而现在...
不过,时间紧迫,我没多少时间了.:(
要是我在应用中总是像你说的这样一般的操作,都用sql语句,是不是会有什么缺点?还有,我以前使用rdo,dbgrid的绑定模式,自动更新,可现在好像不好使了,
好像少了什么设置?
因为我现在是侧重于整个系统的制作,时间紧迫,我只能先用最简单的方法县实现整个
功能再说,(别告诉我用dao).还有,谁有vc 操作dmo之类的资料啊?我看到的都是vb方面的!
中调试,发现是在m_pSet->Update()出的错.
既然大家说那么作没错,我怀疑是数据库的问题,可是到底是怎么回事呢?
//After declaration
try
{
hr=m_pConnection.CreateInstance(__uuidof(Connection));
hr=m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pConnection->Open(Connect,"","",-1);
//实现记录的添加
_bstr_t bstrSQL="insert into yourtable values ('col1','col2')";
m_pConnection->Execute(bstrSQL, NULL, -1);
m_pRecordset->Close();
m_pConnection->Close();
}
catch(...)
{
//MessageBox("抛出异常,程序将关闭!");
}