Dim StrCon
Dim Res,Cmd
Set Res = CreateObject("ADODB.Recordset")
Set Cmd = CreateObject("ADODB.Command")
'以下为建立连接
StrCon ="Driver={Microsoft ODBC for Oracle};Server=servername;Uid=usernamewd=password;"
Cmd.activeconnection=StrCon
Cmd.CommandType =1
'以下为执行sql ,根据实际情况替换之
Cmd.CommandText="select count( *) from spaces "
Set Res = Cmd.Execute()
'展示结果
Do while not Res.eof
Msgbox(Res(0))
Res.MoveNext
Loop
'以下为关闭数据库连接
Set Res=nothing
Set Cmd.activeconnection=nothing
Set Cmd=nothing