Android Programming Press on the image to return to the main documentation page.

iSQL

List of types:

ResultSet
SQL

ResultSet


Events:

None

Members:


  Close

  ColumnCount As Int [read only]

  GetBlob (ColumnName As String) As Byte()

  GetBlob2 (Index As Int) As Byte()

  GetColumnName (Index As Int) As String

  GetDouble (ColumnName As String) As Double

  GetDouble2 (Index As Int) As Double

  GetInt (ColumnName As String) As Int

  GetInt2 (Index As Int) As Int

  GetLong (ColumnName As String) As Long

  GetLong2 (Index As Int) As Long

  GetString (ColumnName As String) As String

  GetString2 (Index As Int) As String

  IsInitialized As Boolean

  NextRow As Boolean

  Tag As Object

Members description:

Close
Closes the ResultSet.
ColumnCount As Int [read only]
Returns the number of columns.
GetBlob (ColumnName As String) As Byte()
Returns the value stored in the specified column as an array of bytes.
GetBlob2 (Index As Int) As Byte()
Returns the value stored in the specified column ordinal as an array of bytes.
GetColumnName (Index As Int) As String
Returns the name of the column at the specified index.
The first column index is 0.
GetDouble (ColumnName As String) As Double
Returns the value stored in the specified column as Double.
GetDouble2 (Index As Int) As Double
Returns the value stored in the specified column ordinal as Double.
GetInt (ColumnName As String) As Int
Returns the value stored in the specified column as Int.
GetInt2 (Index As Int) As Int
Returns the value stored in the specified column ordinal as Int.
GetLong (ColumnName As String) As Long
Returns the value stored in the specified column as Long.
GetLong2 (Index As Int) As Long
Returns the value stored in the specified column ordinal as Long.
GetString (ColumnName As String) As String
Returns the value stored in the specified column as String.
GetString2 (Index As Int) As String
Returns the value stored in the specified column ordinal as String.
IsInitialized As Boolean
Tests whether this object was initialized.
NextRow As Boolean
Moves to the next row and returns true if there is such a row.
You should always call NextRow before trying to get a value from the ResultSet.
Example:
Dim rs As ResultSet = SQL1.ExecQuery2("SELECT * FROM table1 WHERE col1 = ?", Array(100))
Do While rs.NextRow
'work with records
Loop
rs.Close
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.

SQL

iSQL.h
iSQL

Created by b4j on 9/10/14.
Copyright (c) 2014 Anywhere Software. All rights reserved.

Events:

QueryComplete (Success As Boolean, Crsr As ResultSet)
NonQueryComplete (Success As Boolean)

Members:


  AddNonQueryToBatch (Statement As String, Args As List)

  BeginTransaction

  Close

  ExecNonQuery (Statement As String)

  ExecNonQuery2 (Statement As String, Args As List)

  ExecNonQueryBatch (EventName As String) As Object

  ExecQuery (Query As String) As ResultSet

  ExecQuery2 (Query As String, Args As List) As ResultSet

  ExecQueryAsync (EventName As String, Query As String, Args As List) As Object

  ExecQuerySingleResult (Query As String) As String

  ExecQuerySingleResult2 (Query As String, Args As List) As String

  Initialize (Dir As String, FileName As String, CreateIfNecessary As Boolean)

  IsInitialized As Boolean

  Rollback

  TransactionSuccessful

Members description:

AddNonQueryToBatch (Statement As String, Args As List)
Adds the command and the parameters to the batch. Call ExecNonQueryBatch to execute the batch.
Example:
For i = 1 To 1000
  sql.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = sql.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log("NonQuery: " & Success)
BeginTransaction
Starts an update transaction.
The code structure should be:
SQL1.BeginTransaction
Try
'block of statements
SQL1.TransactionSuccessful
Catch
SQL1.Rollback 'cancel the transaction
Log("Error: " & LastException)
End Try
Close
Closes the database.
ExecNonQuery (Statement As String)
Executes a non query statement (statement other than SELECT).
Make sure to explicitly create a transaction if executing more than a few statements.
ExecNonQuery2 (Statement As String, Args As List)
Executes a non query statement (statement other than SELECT).
Make sure to explicitly create a transaction if executing more than a few statements.
The query can include question marks which will be correctly replaced with the values from the list.
Example:
SQL1.ExecNonQuery2("INSERT INTO table1 VALUES (?, ?, 0)", Array ("some text", 2))
ExecNonQueryBatch (EventName As String) As Object
Asynchronously executes all the commands previously added with AddNonQueryToBatch. The NonQueryComplete event will be raised.
Returns an object that can be used as the sender filter in Wait For calls.
Example:
For i = 1 To 1000
  sql.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = sql.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log("NonQuery: " & Success)
ExecQuery (Query As String) As ResultSet
Executes a SELECT query and returns a ResultSet which is used to go over the results.
Example:
Dim rs As ResultSet = SQL1.ExecQuery("SELECT col1, col2 FROM table1")
Do While rs.NextRow
Log(Cursor.GetString("col1")
Loop
ExecQuery2 (Query As String, Args As List) As ResultSet
Executes a SELECT query and returns a ResultSet which is used to go over the results.
Example:
Dim rs As ResultSet = SQL1.ExecQuery2("SELECT col1, col2 FROM table1 WHERE col3 = ?", Array (22))
Do While rs.NextRow
Log(Cursor.GetString("col1")
Loop
ExecQueryAsync (EventName As String, Query As String, Args As List) As Object
Asynchronously executes the given query. The QueryComplete event will be raised when the results are ready.
Returns an object that can be used as the sender filter for Wait For calls.
Example:
Dim SenderFilter As Object = sql.ExecQueryAsync("SQL", "SELECT * FROM table1", Null)
Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet)
If Success Then
  Do While rs.NextRow
    Log(rs.GetInt2(0))
  Loop
  rs.Close
Else
  Log(LastException)
End If
ExecQuerySingleResult (Query As String) As String
Executes the query and returns the value in the first column of the first row. Returns an empty string if no value was found.
Example:
Dim NumberOfMatches As Int = SQL1.ExecQuerySingleResult("SELECT count(*) FROM table1 WHERE col2 > 300")
ExecQuerySingleResult2 (Query As String, Args As List) As String
Executes the query and returns the value in the first column of the first row. Returns an empty string if no value was found.
Example:
Dim NumberOfMatches As Int = SQL1.ExecQuerySingleResult2("SELECT count(*) FROM table1 WHERE col2 > ?", Array(300))
Initialize (Dir As String, FileName As String, CreateIfNecessary As Boolean)
Initializes the database file. A new database will be created if the file does not exist (and CreateIfNecessary is true).
The database file cannot be located in the assets folder.
IsInitialized As Boolean
Rollback
Rollbacks the transaction (cancels it).
TransactionSuccessful
Commits the transaction and ends it.
Top