EXCEL VBA 如何在不安装oracle客户端情况连接oracle服务器。 10
1个回答
展开全部
Dim cn As New ADODB.Connection '定义数据链接对象 ,保存连接数据库信息;请先添加ADO引用
Dim rs As New ADODB.Recordset '定义记录集对象,保存数据表
Dim strCn As String, strSQL As String '字符串变量
Dim i As Integer, j As Integer, sht As Worksheet
strCn = "Provider=MSDAORA.1;Password="psw";User ID="userid";Data Source="DB";Persist Security Info=True" strSQL = "select * from tab"
cn.Open strCn
rs.Open strSQL, cn
xrow = 1
Do While (Not rs.EOF)
Sheet1.Cells(xrow, 1) = rs.Fields().Item(0)
....
xrow = xrow + 1
rs .MoveNext
Loop
End Sub
Dim rs As New ADODB.Recordset '定义记录集对象,保存数据表
Dim strCn As String, strSQL As String '字符串变量
Dim i As Integer, j As Integer, sht As Worksheet
strCn = "Provider=MSDAORA.1;Password="psw";User ID="userid";Data Source="DB";Persist Security Info=True" strSQL = "select * from tab"
cn.Open strCn
rs.Open strSQL, cn
xrow = 1
Do While (Not rs.EOF)
Sheet1.Cells(xrow, 1) = rs.Fields().Item(0)
....
xrow = xrow + 1
rs .MoveNext
Loop
End Sub
追问
如果不安装oracle客户端,没有连接组件式不能连接数据库成功的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询