刚好写过:
Option Explicit
Private Sub Command1_Click()
'需要安装oracle客户端驱动
Dim t As String
Dim txt As String
Dim cn As New ADODB.Connection
Dim cmd As New
Dim rs As New ADODB.Recordset
Me.Caption = "wait..."
Text1 = ""
On Error GoTo Er1
With cn
If .State = adStateOpen Then
.Close
End If
.CursorLocation = adUseClient
.ConnectionString = " Provider=OraOLEDB.Oracle;Password=111111;User ID=myuser01;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST =192.168.166.142)(PORT=1521))) (CONNECT_DATA=(SERVICE_NAME=orcl)));Persist Security Info=True "
.CommandTimeout = 0
.Open
End With
cmd.ActiveConnection = cn
= "select subsys_no, menuid, subsys_id, funcname, funccode, funcimg, sort_no, issub, btnname, parentfunc from xt_func"
Set rs = cmd.Execute
If Not rs.EOF Then
t = rs("menuid") + "," + rs("funcname")
txt = txt + t + vbCrLf
End If
rs.Close
cn.Close
Set rs = Nothing
Set cmd = Nothing
Set cn = Nothing
Text1 = txt
Me.Caption = "ok"
Exit Sub
Er1:
Me.Caption = "error"
Text1 = Err.Description
Err.Clear
Set rs = Nothing
Set cmd = Nothing
Set cn = Nothing
End Sub
这个能用
[此贴子已经被作者于2017-7-21 10:45编辑过]