shohei blog

月別: 2012年2月

OpenOffice Base BasicでSQLクエリを送るときのコツ

・タイムスタンプをSQLに埋め込みたい時は変換する

Dim NowText as string

NowText = now()
NowText = Replace(NowText,”/”,”-“)

・接続はこんな感じ

Dim oDoc
Dim Connection

‘ フォームオブジェクト取得
oDoc = ThisComponent

‘ 接続を取得
oForm = oDoc.getDrawPage().getForms().getByName(“MainForm”)
Connection = oForm.ActiveConnection

‘SQLを発行する
Statement = Connection.createStatement()
ResultSet = Statement.executeQuery(“SELECT “”HOGE”” FROM tbl_FugaFuga”)

‘ 接続を閉じる
ResultSet.Close()
Statement.Close()