JasonDBurke
Programmer
hey,
have a question about CDatabase and CRecordset. I'm accessing MS SQLserver and my client has all privledges are set to Insert Delete and Update. I can view info from the database fine with the recordset but when i try and change the parameters and use an UPDATE or DELETE sql statement i get a "Runtime error
Program: <pathname>
abnormal program termination"
//THIS CODE WORKS FINE
sSql = "SELECT ALERT_ALARMID "
"FROM Alarm_Info "
"ORDER BY ALERT_ALARMID";
CDatabase DB;
DB.OpenEx(NULL,0);
CRecordset Record(&DB);
Record.Open(CRecordset::forwardOnly, sSql,
CRecordset::readOnly);
Record.GetFieldValue("ALERT_ALARMID", sItem1);
DB.CommitTrans();
DB.Close();
//THIS CODE THROWS THE ERROR
sSql = "DELETE Alarm_Info "
"WHERE ALERT_ALARMID = 123";
CDatabase DB;
DB.OpenEx(NULL,0);
CRecordset Record(&DB);
Record.Open(CRecordset::dynaset, sSql,
CRecordset::none); //i've tried many variations
DB.CommitTrans();
DB.Close();
//i have read that Recordset allows only for reading however it it has all the params for updating and appending as well. Is there a better way of going about doing this?
I would just like to try and append or insert. This should be very easy. Also i am completely staying away from any of the class wizard stuff mainly because this particular file doesn't have the privledge of MFC. I just would like to manually update a record. Thanx for any feedback..sample code would be great!!
Jason
have a question about CDatabase and CRecordset. I'm accessing MS SQLserver and my client has all privledges are set to Insert Delete and Update. I can view info from the database fine with the recordset but when i try and change the parameters and use an UPDATE or DELETE sql statement i get a "Runtime error
Program: <pathname>
abnormal program termination"
//THIS CODE WORKS FINE
sSql = "SELECT ALERT_ALARMID "
"FROM Alarm_Info "
"ORDER BY ALERT_ALARMID";
CDatabase DB;
DB.OpenEx(NULL,0);
CRecordset Record(&DB);
Record.Open(CRecordset::forwardOnly, sSql,
CRecordset::readOnly);
Record.GetFieldValue("ALERT_ALARMID", sItem1);
DB.CommitTrans();
DB.Close();
//THIS CODE THROWS THE ERROR
sSql = "DELETE Alarm_Info "
"WHERE ALERT_ALARMID = 123";
CDatabase DB;
DB.OpenEx(NULL,0);
CRecordset Record(&DB);
Record.Open(CRecordset::dynaset, sSql,
CRecordset::none); //i've tried many variations
DB.CommitTrans();
DB.Close();
//i have read that Recordset allows only for reading however it it has all the params for updating and appending as well. Is there a better way of going about doing this?
I would just like to try and append or insert. This should be very easy. Also i am completely staying away from any of the class wizard stuff mainly because this particular file doesn't have the privledge of MFC. I just would like to manually update a record. Thanx for any feedback..sample code would be great!!
Jason