求救,vb+oracle set rs=conn.excute(strsql)执行没问题, 用rs.open strsql,conn,3,1 报错
代码如下-----------------------------------------------------------------------------
外部传入的对象连接字符串:
cnOracle:
With mcnOracle
If .State = 1 Then .Close
.Provider = "MsDataShape"
.Open "Driver={Microsoft ODBC for Oracle};Server=" & mstrServer, mstrUser, mstrPass
End With
--------------------------------------------------------------------------
问题程序代码:
public gcnOracle as adodb.connection
public function ISHasDepartment(cnOracle as adodb.connection) as boolen
Dim rsTmp As ADODB.Recordset
On Error GoTo Err
Set gcnOracle = cnOracle ''cnoracle是外部传进来的连接
Set gcnOracle = cnOracle
Set rsTmp = gcnOracle.Execute("select * from Department") ''执行通过
If rsTmp.State = 1 Then rsTmp.Close
rsTmp.Open "select * from Department", gcnOracle, adOpenDynamic, adLockReadOnly 执行报错
if rstmp.recordcount >0 then ISHasDepartment=true
exit sub
ERR:
msgbox err.description
end sub
------------------------------------------------------------------------
我查了好久的原因,外部程序体的 mcnOracle 这样用没问题,就传入的时候赋值到 全局变量gcnOracle 后,就报错了,两个ado的版本都是2.5的,请各位有经验的大侠给指点指点,在此拜谢了 vb+oracle --------------------编程问答-------------------- rsTmp.Open "select * from Department", gcnOracle, adOpenDynamic, adLockReadOnly 执行报错
要这样操作,则在open之前,必须:
set rsTmp=new adodb.recordset
使用execute操作,则ado会内部为加载的数据创建记录集 --------------------编程问答-------------------- 我试过了,不行啊仍然报错 ,到底是什么原因呢,直接在主程序中使用 rs.open没有问题,但是当将这个cn传入到 com组件中,这样用就不行了,求解 --------------------编程问答-------------------- cnOracle as adodb.connection
既然已经传进来了,为何不直接用cnOracle打开呢?
补充:VB , 数据库(包含打印,安装,报表)