「Libreoffice VBA」:修訂間差異
跳至導覽
跳至搜尋
新頁面: 相容指令 Option VBASupport 1 |
無編輯摘要 |
||
| 第1行: | 第1行: | ||
==相容指令== | |||
Option VBASupport 1 | Option VBASupport 1 | ||
==SQL輸入範例== | |||
Option VBASupport 1 | |||
Private Sub CommandButton1_Click() | |||
Dim I As Integer | |||
Dim cn As New ADODB.Connection | |||
Dim strCn As String, strSQL As String | |||
strCn = "Provider=sqloledb;Server=192.168.1.xx;Database=DEMO;Uid=xx;Pwd=xxxx;" | |||
cn.Open strCn | |||
I = 2 | |||
Do While Cells(I, 1) <> "" | |||
strSQL = "UPDATE PURTD set TD012='" & Range("E" & I) & "' where TD001='" & Range("A" & I) & "' and TD002='" & Range("B" & I) & "' and TD003='" & Range("C" & I) & "'" | |||
'底下寫執行sql語法 | |||
cn.Execute strSQL | |||
I = I + 1 | |||
Loop | |||
cn.Close | |||
Set cn = Nothing | |||
MsgBox "執行完成" | |||
End Sub | |||
於 2014年11月14日 (五) 08:07 的修訂
相容指令
Option VBASupport 1
SQL輸入範例
Option VBASupport 1
Private Sub CommandButton1_Click()
Dim I As Integer
Dim cn As New ADODB.Connection
Dim strCn As String, strSQL As String
strCn = "Provider=sqloledb;Server=192.168.1.xx;Database=DEMO;Uid=xx;Pwd=xxxx;"
cn.Open strCn
I = 2
Do While Cells(I, 1) <> ""
strSQL = "UPDATE PURTD set TD012='" & Range("E" & I) & "' where TD001='" & Range("A" & I) & "' and TD002='" & Range("B" & I) & "' and TD003='" & Range("C" & I) & "'"
'底下寫執行sql語法
cn.Execute strSQL
I = I + 1
Loop
cn.Close
Set cn = Nothing
MsgBox "執行完成"
End Sub