Click to See Complete Forum and Search --> : ! SQL help with Update! (I think)


May 18th, 1999, 04:47 AM
Here is my code, and I keep getting an error. I want to update an Access record that has more records than this. It reads them just fine when I change the SQL to a select statement.

CDatabase m_dbEdit;
CRecordset rsEdit;
CString strConnect;
strConnect ="ODBC;DSN=database;UID=;PW=;";
m_dbEdit.Open("",FALSE,FALSE,strConnect,FALSE);
CString strSQL;
strSQL = _T("UPDATE table SET Variable='edited' WHERE ID=1");
rsEdit.Open(CRecordset::snapshot, strSQL);
rsEdit.Close( );
m_dbEdit.Close( );

John Holifield
May 18th, 1999, 01:09 PM
You don't need to use the CRecordset to do an update. Just do something like:

CString strSQL;
strSQL = _T("UPDATE table SET Variable='edited' WHERE ID=1");

myOpenDatabase.ExecuteSQL(strSQL);