<div class="meta" robots="noindex">

</div>

Property

# Database_Class.ErrorCode

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `DatabaseException</api/exceptions/databaseexception>` as a replacement.

</div>

## Description

The error code returned from the database. Error codes and error messages are different for each database.

## Notes

You should check the Error property after each database operation to see if there was an error. If there is an error, you can display or log the <span class="title-ref">ErrorCode</span> and ErrorMessage.

- [SQLite error codes](http://sqlite.org/c3ref/c_abort.html)
- [PostgreSQL error codes](http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html)
- [MySQL error codes](http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html)
- [Oracle error codes](http://docs.oracle.com/cd/B28359_01/server.111/b28278/toc.htm)
- MS SQL Server error codes: SELECT \* FROM SYS.MESSAGES

## Sample code

This code attempts to create an in-memory SQLite database and displays the error if one occurred:

``` xojo
Dim db As New SQLiteDatabase
If db.Connect Then
  ' Connected to in-memory database
Else
  If db.Error Then
    MsgBox("Error: " + Str(db.ErrorCode) + " - " + db.ErrorMessage)
  End If
End If
```

## Compatibility

All project types on all supported operating systems.
