Public Function OracleConnection()
Dim conn '定义一个数据库连接串
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString ="Provider=OraOLEDB.Oracle.1;Password=1qaz2wsx;Persist Security Info=True;User ID=ticket;Data Source=ticket"
conn.Open '打开数据库连接
If conn.State = 0 Then '判断数据库连接是否成功
Reporter.ReportEvent micFail , "testing","连接数据库失败"
Else
Reporter.ReportEvent micPass,"testing","连接数据库成功"
End If
If conn.State<> 0 then
Set Rs=CreateObject("ADODB.Recordset") '生成记录集对象
strsql ="Delete from ty_service_providers t where t.service_name!='途游'" '从数据库中查询ty_service_providers的所有记录
Rs.Open strsql ,conn,1,3 '执行sql语句,记录可以自由移动,单数记录处于只读模式
'firstName=Rs("service_name") '取得字段为service_name的记录,游标定义在第一行,所以取得的是该字段所在行的第一行数据
'msgbox firstName
End If
End Function