Difference between revisions of "Database.ErrorMessage"

From Xojo Documentation

(SMBot: new page by automated transformation)
 
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{Deprecated|version=2019r2|replacement=[[DatabaseException]]}}
 
{{PropertyBox
 
{{PropertyBox
 
| name=ErrorMessage
 
| name=ErrorMessage
| owner=[[Database]]
+
| owner=[[Database_Class|Database]]
 
| ownertype=class
 
| ownertype=class
 
| scope=public
 
| scope=public
 
| type=[[String]]
 
| type=[[String]]
 
| platform=all
 
| platform=all
 +
| readonly=yes
 
}}
 
}}
Text of the error message returned from the database engine. Error codes and error messages are different for each engine.
+
{{Description
 +
|text = Text of the error message 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 ErrorCode and ErrorMessage.
 +
 
 +
== Sample Code ==
 +
This code attempts to create an in-memory SQLite database and displays the error if one occurred:
 +
<rbcode>
 +
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
 +
</rbcode>

Latest revision as of 20:51, 20 May 2019

Read-Only Property (As String )
StringValue = aDatabase.ErrorMessage

Supported for all project types and targets.

Text of the error message 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 ErrorCode and ErrorMessage.

Sample Code

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

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