Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Error Handling

Status
Not open for further replies.

lszb75

Technical User
Apr 4, 2003
5
HU
How can I handle the different ado error messages?
e.g. With the EDataBaseError I can't seperate the errors caused by postings. Can anyone help me?
 
You should be able to use the Errors collection property of the TADOConnection component.

What DBMS are you using?

For example, with Gupta SQL Base, something like the following can be used (HMAIN is a TADOConnection):
Code:
   except
       on E:Exception do
       begin
         case HMAIN.Errors.Item[0].NativeError of
           404: sLastError := 'Invalid Password.';
           405: sLastError := 'Invalid User Name.'
         else
           sLastError := 'Login Failed.  Error number: '
                      + IntToStr(HMAIN.Errors.Item[0].NativeError)
                      +#13#10+e.message;
         end; {case}
 
hi. connect to MS SQL

procedure TDataModul.ConnectMSSQL;
var
UserID: string;
Source: string;
begin
UserID := 'blabla';
Source := 'blaSOurce';

dbConnect := 'Provider=Sqloledb.1;Persist Security Info=False;' +
'User ID=' + UserID + ';Initial Catalog=InfoForm;Data Source=' + Source;

try
ConnectTables; //Call proc to connect wanted tables..
except
begin
//error connection..
MessageDlg('Can not connect to SQL base!' + #13#10 +
'Application close!', mtError, [mbOK], 0);
MainForm.Close;
end;
end;

end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top