21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Database Access 205<br />

""Customer""")<br />

If Not IsNull(ResultSet) Then<br />

While ResultSet.next<br />

MsgBox ResultSet.getString(1)<br />

Wend<br />

End If<br />

Once the database connection has been established, the code used in the example first uses<br />

the Connection.createObject call to create a Statement object. This Statement object then<br />

uses the executeQuery call to return the actual ResultSet. The program now checks<br />

whether the ResultSet actually exists and traverses the data records using a loop. The<br />

values required (in the example, those from the CustomerNumber field) returns the<br />

ResultSet using the getString method, whereby the parameter 1 determines that the call<br />

relates to the values of the first column.<br />

The ResultSet object from SDBC is comparable with the Recordset object from DAO and ADO, since<br />

this also provides iterative access to a database.<br />

The database is actually accessed in <strong>OpenOffice</strong>.<strong>org</strong> through a ResultSet object. This reflects the<br />

content of a table or the result of a SQL-SELECT command. In the past, the ResultSet object provided<br />

the resident methods in the Application object for navigation within the data, for example,<br />

DataNextRecord ).<br />

Type- Specific Methods for Retrieving Values<br />

As can be seen in the example from the previous section, <strong>OpenOffice</strong>.<strong>org</strong> provides a<br />

getString method for accessing table contents. The method provides the result in the form<br />

of a string. The following get methods are available:<br />

getByte()<br />

supports the SQL data types for numbers, characters and strings<br />

getShort()<br />

getInt()<br />

supports the SQL data types for numbers, characters and strings<br />

supports the SQL data types for numbers, characters and strings<br />

getLong()<br />

supports the SQL data types for numbers, characters and strings<br />

getFloat()<br />

supports the SQL data types for numbers, characters and strings<br />

getDouble()<br />

supports the SQL data types for numbers, characters and strings<br />

getBoolean()<br />

supports the SQL data types for numbers, characters and strings<br />

getString()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!