MBS Xojo Developer Conference and Training
Join us from 11th to 14th September 2013 in Koblenz.
Join us from 11th to 14th September 2013 in Koblenz.
Platforms to show: All Mac Windows Linux Cross-Platform
SQLConnectionMBS class
class, SQL,
MBS Real Studio SQL Plugin
(SQL),
class SQLConnectionMBS,
Plugin version: 9.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.
Function: The class for a SQL Plugin Database connection.
Example:
Notes:
Supported databases: Oracle, Microsoft SQL Server, DB2, Sybase, Informix, InterBase/Firebird, SQLBase, MySQL, PostgreSQL and ODBC and SQLite
Plugin version: 9.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.
Function: The class for a SQL Plugin Database connection.
Example:
dim con as new SQLConnectionMBS
try
// where is the library?
con.SetFileOption con.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")
// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC
dim server as string = "192.168.1.80:3306@test"
con.Connect(server,"root","",SQLConnectionMBS.kMySQLClient)
MsgBox "We are connected!"
// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect
msgbox "We are disconnected!"
catch r as RuntimeException
MsgBox r.message
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
// on error rollback changes
con.Rollback
catch rr as runtimeexception
MsgBox rr.message
end try
end try
- event Working
- property AutoCommit as integer
- property Client as integer
- property IsolationLevel as integer
- property Option(name as string) as string
- method ClientVersion as integer
- method Commit
- method Connect(DBString as string, UserID as string, Password as string, client as integer = 0)
- method Disconnect
- method Error as Boolean
- method ErrorCode as Integer
- method ErrorMessage as string
- method isAlive as boolean
- method isConnected as boolean
- method NativeAPI as variant
- method Rollback
- method ServerVersion as integer
- method ServerVersionString as string
- method SetFileOption(name as string, file as folderitem)
- method SQLExecute(command as string, CommandType as integer = 0)
- method SQLExecuteMT(command as string, CommandType as integer = 0)
- method SQLSelect(command as string, CommandType as integer = 0) as string
- method SQLSelectAsRecordSet(command as string, CommandType as integer = 0) as RecordSet
- method SQLSelectAsRecordSetMT(command as string, CommandType as integer = 0) as RecordSet
- method SQLSelectMT(command as string, CommandType as integer = 0) as string
- const kOptionAPPNAME = "APPNAME"
- const kOptionLibrarySeparator = ":"
- const kOptionWSID = "WSID"
Isolation Levels
| Constant | Value | Description |
|---|---|---|
| kANSILevel0 | 0 |
ANSI Level 0 |
| kANSILevel1 | 1 |
ANSI Level 1 |
| kANSILevel2 | 2 |
ANSI Level 2 |
| kANSILevel3 | 3 |
ANSI Level 3 |
| kLevelUnknown | -1 |
Unknown |
| kReadCommitted | 1 |
Read committed. |
| kReadUncommitted | 0 |
Read uncommitted. |
| kRepeatableRead | 2 |
Repeatable read. |
| kSerializable | 3 |
Serializable. |
Values for autocommit property
| Constant | Value | Description |
|---|---|---|
| kAutoCommitOff | 0 |
Autocommit is off. |
| kAutoCommitOn | 1 |
Autocommit is on. |
| kAutoCommitUnknown | -1 |
Autocommit unknown |
The database client constants
| Constant | Value | Description |
|---|---|---|
| kClientNotSpecified | 0 |
Client is not specified. |
| kDB2Client | 6 |
DB2 client. |
| kFirebirdClient | 4 |
InterBase/Firebird client. |
| kInformixClient | 7 |
Informix client. |
| kInterBaseClient | 4 |
InterBase/Firebird client. |
| kMySQLClient | 9 |
MySQL client. |
| kODBCClient | 1 |
ODBC client. |
| kOracleClient | 2 |
Oracle client. For Windows the file is "oci.dll", for Linux libclntsh.so and for Mac OS X libclntsh.dylib. |
| kPostgreSQLClient | 10 |
PostgreSQL client. |
| kSQLBaseClient | 5 |
SQLbase client. |
| kSQLiteClient | 11 |
SQLite client. Or spatialite. |
| kSQLServerClient | 3 |
Mircosoft SQL Server client. You may need to download the client packages for accessing SQL Server. Files like the SQLNCLI dll may be missing. You can download for example the Feature Pack for Microsoft SQL Server 2005 from the microsoft download page. |
| kSybaseClient | 8 |
Sybase client. |
Options to specify the library with SetFileOption
| Constant | Value | Description |
|---|---|---|
| kOptionLibraryDB2 | "DB2CLI.LIBS" |
for DB2. |
| kOptionLibraryFirebird | "IBASE.LIBS" |
for Firebird. |
| kOptionLibraryInformix | "INFCLI.LIBS" |
for Informix. |
| kOptionLibraryInterbase | "IBASE.LIBS" |
for Interbase. |
| kOptionLibraryMySQL | "MYSQL.LIBS" |
for MySQL. Library extension on Mac is ".dylib", on Linux ".so" and on Windows ".dll". You get this library with the MySQL download on their homepage. |
| kOptionLibraryODBC | "ODBC.LIBS" |
for ODBC. |
| kOptionLibraryOracle | "OCI8.LIBS" |
for Oracle. |
| kOptionLibraryPostgreSQL | "LIBPQ.LIBS" |
for Postgre SQL. |
| kOptionLibrarySQLBase | "SQLBASE.LIBS" |
for SQLbase. |
| kOptionLibrarySQLite | "SQLITE.LIBS" |
for SQLite. Can also be the spatialite library. |
| kOptionLibrarySybaseComn | "SYBCOMN.LIBS" |
for Sybase. |
| kOptionLibrarySybaseCS | "SYBCS.LIBS" |
for Sybase. |
| kOptionLibrarySybaseCT | "SYBCT.LIBS" |
for Sybase. |
| kOptionLibrarySybaseIntl | "SYBINTL.LIBS" |
for Sybase. |
| kOptionLibrarySybaseTCL | "SYBTCL.LIBS" |
for Sybase. |
This class has no sub classes.
Some methods using this class:
- MySQLMBS.AffectedRows(Conn as SQLConnectionMBS) as UInt64
- MySQLMBS.Error(Conn as SQLConnectionMBS) as string
- MySQLMBS.ErrorNumber(Conn as SQLConnectionMBS) as UInt32
- MySQLMBS.FieldCount(Conn as SQLConnectionMBS) as UInt32
- MySQLMBS.Info(Conn as SQLConnectionMBS) as string
- MySQLMBS.InsertID(Conn as SQLConnectionMBS) as Int64
- MySQLMBS.SetSSL(Conn as SQLConnectionMBS, keyPath as string, CertificatePath as string, AuthorityPath as string, authorityFolderPath as string, Cipher as string)
- PostgreSQLAPIMBS.DB(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.ErrorMessage(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Host(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Options(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Password(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.Port(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.TTY(conn as SQLConnectionMBS) as string
- PostgreSQLAPIMBS.User(conn as SQLConnectionMBS) as string
- SQLCommandMBS.Constructor(connection as SQLConnectionMBS, SQLCommand as String, CommandType as integer=0)
- SQLDatabaseMBS.GetConnection as SQLConnectionMBS
- SQLite3MBS.BackupInit(Dest as SQLConnectionMBS, DestName as String, Source as SQLConnectionMBS, SourceName as String) as SQLite3BackupMBS
- SQLite3MBS.ErrCode(Conn as SQLConnectionMBS) as integer
- SQLite3MBS.ErrMessage(Conn as SQLConnectionMBS) as string
- SQLite3MBS.LastInsertRowID(Conn as SQLConnectionMBS) as Int64
Some properties using for this class:
Some examples which use this class:
- /SQL/DB2 Connect
- /SQL/Firebird Connect
- /SQL/Informix Connect
- /SQL/Microsoft SQL Connect
- /SQL/Microsoft SQL via ODBC
- /SQL/MySQL Connect
- /SQL/MySQL ExecuteSQL
- /SQL/MySQL ExecuteSQL with Parameters
- /SQL/MySQL Fetch rows bulk
- /SQL/MySQL Fetch values
- /SQL/MySQL Update values
- /SQL/MySQL Write blob to file
- /SQL/ODBC Connect
- /SQL/Oracle Connect
- /SQL/PostgreSQL API
- /SQL/PostgreSQL Connect
- /SQL/PostgreSQL RecordCount
- /SQL/Reporting From A Database/Reports Example with MBS
- /SQL/SQL Exception Tests
- /SQL/SQLDatabaseMBS MSSQL Connect
- /SQL/SQLDatabaseMBS MySQL Connect
The items on this page are in the following plugins: MBS Real Studio SQL Plugin.
Links
MBS Real Studio Plugins