Public Function CommitNumber(ExeDelete As String, ExeInsert As String, cn As ADODB.Connection) As Boolean 'Test wether there is some error bellow, if it happens, call a Error Deal function
On Error GoTo ErrorDeal
' Dim cn As ADODB.Connection
' Set coon = New ADODB.Connection
' coon = cn
'Run a Sql command to delete a record
cn.Execute (ExeDelete)
'Run a Sql command to insert a record
cn.Execute (ExeInsert)
'Successfuly finished, return true
CommitNumber = True
Exit Function 'Deal with the error occured above
ErrorDeal: 'Quotate the error class
ErrorManage
'Error occured, return false
CommitNumber = False
End Function
我在主过程中 向着个函数传入一个 连接对象
准备利用这个对象 对数据库进行操作 可在 cn.excute (sql) 的过程中 总是程序停止响应我分析是 cn连接 有问题 但调试的时候 cn 是传进来了的
我很纳闷 难道 连接对象 不能当作 参数传递 ?
清 高手指教 我主要是想实现程序的模块化
另外 在vb中 可以在一个模块中定义 多个块公用的全局常量吗 怎么用的 如果不容易听懂的地方 请贴下代码 非常感谢 ~~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货