Hello, I'm having some issues with memory leaks. I found that it is better to use EMSError rather than EDAError when possible, but also found that DBACcess doesn't have EMSError, but oledbaccess does. Should i be using oledbaccess instead of dbaccess in all places in my program? Thanks in advance,
Ben
dbaccess.hpp or oledbaccess.hpp
Re: dbaccess.hpp or oledbaccess.hpp
And if so, how do I get my program to use it? OnError defaults to using the DAError. Is there some way to change that? I ask because a leak program is telling me that this line (E->IsKeyViolation) is causing a memory leak:
Code: Select all
void __fastcall TiSETDBObj::SDACError(TObject *Sender, EMSError *E,bool &Fail)
{
if (!E->IsKeyViolation()) { // key violations are caught by the calling function...catching
// them here would just add unneccesary lines to the log file
AnsiString msg,msg2;
msg2 = DateTimeStamp();
msg = ShortStamp(msg2);
msg2 = "\n> " + msg + " - ***New Error***";
iSET->WriteToDBLog(msg2);
if (E->ErrorCode == 1205 || E->ErrorCode == 1222) {
Fail = false; // now the error won't get passed through for these 2 errors...meaning a popup won't show up
iSET->LockTimeoutCount++;
for (int i = 0; i < CurrentQuery->SQL->Count; i++) {
msg = CurrentQuery->SQL->Strings[i] + "\n";
iSET->WriteToDBLog(msg);
}
msg = "\n Parameters: \n";
iSET->WriteToDBLog(msg);
for (int i = 0; i < CurrentQuery->Params->Count; i++) {
msg = (AnsiString)i + CurrentQuery->Params->Items[i]->AsString + "\n";
iSET->WriteToDBLog(msg);
}
}
msg = "ErrorCode: " + (AnsiString)E->ErrorCode;
iSET->WriteToDBLog(msg);
msg = "ErrorMessage: " + E->Message;
iSET->WriteToDBLog(msg);
if (E->IsFatalError()) {
msg = "This is a Fatal Error";
iSET->WriteToDBLog(msg);
} else {
msg = "This is NOT a Fatal Error";
iSET->WriteToDBLog(msg);
}
if (E->IsKeyViolation()) {
msg = "This is a Key Violation\n";
iSET->WriteToDBLog(msg);
} else {
msg = "This is NOT a Key Violation\n";
iSET->WriteToDBLog(msg);
}
}
}
Re: dbaccess.hpp or oledbaccess.hpp
Hello,
You can use any of these classes. The EDAError class is a base error class for all DAC products, it contains only the base information about the error. The EMSError class is a descedant of the EDAError class, it contains not only the base information about the error, but the SQL Server specific error information as well.
The actual class type that is returned in the OnError event is EMSError, so if you want to use EMSError, you should cast the E variable to EMSError. Here is an example:
I cannot reproduce the problem with memory leak. Please try creating a sample program that demonstrates this problem and send it to andreyz*devart*com . Also, please specify the following:
- the tool you use for tracing memory leaks;
- the exact version of SDAC. You can learn it from the About sheet of TMSConnection Editor;
- the exact version of your IDE;
- the exact version of SQL Server and client. You can learn it from the Info sheet of TMSConnection Editor.
You can use any of these classes. The EDAError class is a base error class for all DAC products, it contains only the base information about the error. The EMSError class is a descedant of the EDAError class, it contains not only the base information about the error, but the SQL Server specific error information as well.
The actual class type that is returned in the OnError event is EMSError, so if you want to use EMSError, you should cast the E variable to EMSError. Here is an example:
Code: Select all
void __fastcall TForm1::MSConnection1Error(TObject *Sender, EDAError *E, bool &Fail)
{
EMSError *erms = (EMSError *)E;
ShowMessage(erms->Message);
}
- the tool you use for tracing memory leaks;
- the exact version of SDAC. You can learn it from the About sheet of TMSConnection Editor;
- the exact version of your IDE;
- the exact version of SQL Server and client. You can learn it from the Info sheet of TMSConnection Editor.