Dear all,
Attached, you will find an external library for direct access to Mysql. Copy the files on the external library directory and also download and save on the same directory, the "mysql-connector-java-5.1.22-bin.jar" (from Oracle).
This external library implements the AdoConnection & AdoRecordset class from the old good days of visual basic 6. Change your android targetSdkVersion to 8, because of known bag.
[Class AdoRecordset]
[Properties]
1.Connection - Gets or sets the AdoConnection associated with the AdoRecordset
2.SqlStatement - Gets or sets the SQL Statement
3.isClosed - Retrieves whether this Recordset object has been closed. A Recordset is closed if the method close has been called on it, or if it is automatically closed
4.MaxRecords - Sets or returns the maximum number of records to return to a AdoRecordset object from a query
[Methods]
1.BOF - Returns true if the current record position is before the first record, otherwise false
2.EOF - Returns true if the current record position is after the last record, otherwise false
3.FieldSet - Sets value to active row's field
4.Field -Returns the Value of field
5.InitializeEvent - Activate the events trigger in case of error
6.Open - Open the recordset
7.Close - Closes the recordset
9.MovePrevious - Moves the record pointer to the previous record
10.MoveNext - Moves the record pointer to the next record
11.MoveFirst - Moves the record pointer to the first record
12.MoveLast - Moves the record pointer to the last record
13.MoveTo - Moves the record pointer to specific record
14.AddNew - Add an empty row
15.Update - Update the recordset (New record or update of existing record)
15.Delete - Delete the active record
16.RecordCount - Return the Recordset rows' number
17.RowNumber - Retrieves the current row number
[Events]
1.Sub AdoRecordsetError (Message as String, State as String, ErrorCode as int)
[Class AdoConnection]
[Properties]
1.UserName - Gets the Username
2.Password - Gets the Password
3.HostIP - Gets the HostIP
4.HostPortNumber - Gets the HostPortNumber
5.CharacterEncoding - Gets the CharacterEncoding
6.SocketTimeout - Gets or set a timeout (in seconds) on network socket operations (0, the default means no timeout), before throwing an error
7.LoginTimeout - Gets or set a the maximum time in seconds that a driver will wait while attempting to connect to a database
8.ConnectionTimeout - Gets or set a timeout (in seconds) for socket connect (0, the default means no timeout). before throwing an error
9.Database - Gets the name of the current database or the database to be used after a connection is opened
10.State - Indicates the state of the AdoConnection when the most recent network operation was performed on the connection
[Methods]
1.Open - Opens a database connection with the property settings specified by the ConnectionString
2.Close - Closes the connection to the database
3.BeginTrans - Starts a database transaction (Warning : It works only on MySQL INNODB tables)
4.CommitTrans - Saves any changes and ends the current transaction. (Warning : It works only on MySQL INNODB tables)
5.RollbackTrans - Cancels any changes made during the current transaction and ends the transaction. (Warning : It works only on MySQL INNODB tables)
6.Execute - Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement
7.ExecuteInsertCommand - Executes the given Insert SQL statement
8.ExecuteQuerySingleResult - Executes the given SQL statement, which returns a single ResultSet object
[Events]
Sub AdoConnectionError (Message as String, State as String, ErrorCode as int)
Following a simple code for access of data as the old time :
Dim AdoConn As AdoConnection
Dim AdoRec As AdoRecordset
Dim Result As Int
Dim ResultS As String
'Replace the values, with your Mysql Server properties
AdoConn.ConnectionString("192.168.43.111","3306","UTF-","demo","demo","demo")
AdoConn.ConnectionTimeout=1
AdoConn.LoginTimeout=1
AdoConn.SocketTimeout=1
'if the mysql driver return error, the subs AdoConnectionError will activate
AdoConn.InitializeEvent
AdoConn.Open
AdoRec.InitializeEvent
AdoRec.Connection=AdoConn
AdoRec.SqlStatement="select * from demo"
AdoRec.Open
If AdoRec.isClosed Then
' Do something
Else
' Do something
End If
If AdoRec.RecordCount>0 Then
Do While Not(AdoRec.EOF)
Log(AdoRec.Field("DemoField"))
AdoRec.MoveNext
Loop
End If
AdoRec.Close
--------------------------------------
I am waiting your feedback
Attached, you will find an external library for direct access to Mysql. Copy the files on the external library directory and also download and save on the same directory, the "mysql-connector-java-5.1.22-bin.jar" (from Oracle).
This external library implements the AdoConnection & AdoRecordset class from the old good days of visual basic 6. Change your android targetSdkVersion to 8, because of known bag.
[Class AdoRecordset]
[Properties]
1.Connection - Gets or sets the AdoConnection associated with the AdoRecordset
2.SqlStatement - Gets or sets the SQL Statement
3.isClosed - Retrieves whether this Recordset object has been closed. A Recordset is closed if the method close has been called on it, or if it is automatically closed
4.MaxRecords - Sets or returns the maximum number of records to return to a AdoRecordset object from a query
[Methods]
1.BOF - Returns true if the current record position is before the first record, otherwise false
2.EOF - Returns true if the current record position is after the last record, otherwise false
3.FieldSet - Sets value to active row's field
4.Field -Returns the Value of field
5.InitializeEvent - Activate the events trigger in case of error
6.Open - Open the recordset
7.Close - Closes the recordset
9.MovePrevious - Moves the record pointer to the previous record
10.MoveNext - Moves the record pointer to the next record
11.MoveFirst - Moves the record pointer to the first record
12.MoveLast - Moves the record pointer to the last record
13.MoveTo - Moves the record pointer to specific record
14.AddNew - Add an empty row
15.Update - Update the recordset (New record or update of existing record)
15.Delete - Delete the active record
16.RecordCount - Return the Recordset rows' number
17.RowNumber - Retrieves the current row number
[Events]
1.Sub AdoRecordsetError (Message as String, State as String, ErrorCode as int)
[Class AdoConnection]
[Properties]
1.UserName - Gets the Username
2.Password - Gets the Password
3.HostIP - Gets the HostIP
4.HostPortNumber - Gets the HostPortNumber
5.CharacterEncoding - Gets the CharacterEncoding
6.SocketTimeout - Gets or set a timeout (in seconds) on network socket operations (0, the default means no timeout), before throwing an error
7.LoginTimeout - Gets or set a the maximum time in seconds that a driver will wait while attempting to connect to a database
8.ConnectionTimeout - Gets or set a timeout (in seconds) for socket connect (0, the default means no timeout). before throwing an error
9.Database - Gets the name of the current database or the database to be used after a connection is opened
10.State - Indicates the state of the AdoConnection when the most recent network operation was performed on the connection
[Methods]
1.Open - Opens a database connection with the property settings specified by the ConnectionString
2.Close - Closes the connection to the database
3.BeginTrans - Starts a database transaction (Warning : It works only on MySQL INNODB tables)
4.CommitTrans - Saves any changes and ends the current transaction. (Warning : It works only on MySQL INNODB tables)
5.RollbackTrans - Cancels any changes made during the current transaction and ends the transaction. (Warning : It works only on MySQL INNODB tables)
6.Execute - Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement
7.ExecuteInsertCommand - Executes the given Insert SQL statement
8.ExecuteQuerySingleResult - Executes the given SQL statement, which returns a single ResultSet object
[Events]
Sub AdoConnectionError (Message as String, State as String, ErrorCode as int)
Following a simple code for access of data as the old time :
Dim AdoConn As AdoConnection
Dim AdoRec As AdoRecordset
Dim Result As Int
Dim ResultS As String
'Replace the values, with your Mysql Server properties
AdoConn.ConnectionString("192.168.43.111","3306","UTF-","demo","demo","demo")
AdoConn.ConnectionTimeout=1
AdoConn.LoginTimeout=1
AdoConn.SocketTimeout=1
'if the mysql driver return error, the subs AdoConnectionError will activate
AdoConn.InitializeEvent
AdoConn.Open
AdoRec.InitializeEvent
AdoRec.Connection=AdoConn
AdoRec.SqlStatement="select * from demo"
AdoRec.Open
If AdoRec.isClosed Then
' Do something
Else
' Do something
End If
If AdoRec.RecordCount>0 Then
Do While Not(AdoRec.EOF)
Log(AdoRec.Field("DemoField"))
AdoRec.MoveNext
Loop
End If
AdoRec.Close
--------------------------------------
I am waiting your feedback