Difference between revisions of "RU/kb/00000231"
From Wiki
Jump to navigationJump to searchm (1 версия) |
|||
Line 47: | Line 47: | ||
<section begin=signature/> | <section begin=signature/> | ||
− | {{ | + | {{SignYear|Sancho|А. Е. Харламенков|2011}} |
<section end=signature/> | <section end=signature/> | ||
{{RUkbMacrosBottom}} | {{RUkbMacrosBottom}} |
Revision as of 16:27, 27 August 2011
Для работы с dbf-файлами можно использовать следующий код:
Dim DatabaseContext As Object
Dim DataSource As Object
Dim Connection As Object
Dim InteractionHandler as Object
Dim Statement As Object
Dim ResultSet As Object
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("Data source 1")
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
Connection = DataSource.ConnectWithCompletion(InteractionHandler)
Statement = Connection.createStatement()
ResultSet = Statement.executeQuery("SELECT * FROM Table 1")
ResultSet.last()
MsgBox ResultSet.getString(2) 'Значение PP'
Statement.ResultSetConcurrency = com.sun.star.sdbc.ResultSetConcurrency.UPDATABLE
Statement.ResultSetType = com.sun.star.sdbc.ResultSetType.SCROLL_INSENSITIVE
ResultSet = Statement.executeQuery("SELECT * FROM Table 1")
ResultSet.last()
ResultSet.updateString(2, "FF") 'Значение PP меняется на FF'
ResultSet.updateRow
Так же для дальнейшей записи в Dbf вместо ResultSet.last() можно написать ResultSet.afterLast()
Более расширенные функции ResultSet см. через
MsgBox ResultSet.DBG_Properties
и
MsgBox ResultSet.DBG_Methods