实在不会了,各位教我怎么改,谢谢了!

womeihuashuo 2004-08-04 09:46:01
请问,这里是哪里除问题了,该怎么改?谢谢!
Private Sub InitConnectObject()
Dim objUtility As epUtility
Dim strCNStr As String
Dim strPath As String
On Error GoTo ErrorHandler
strPath = App.Path
If Right(strPath, 1) = "\" Then
strPath = Left(strPath, Len(strPath) - 1)
Else
End If
strCNStr = "Provider=Microsoft.Jet.OLEDB.3.51;Password="""";Persist Security Info=True;Data Source=" & strPath & "\Epinfo2.mdb"
Set gadoCN = New ADODB.Connection
gadoCN.ConnectionString = strCNStr
gadoCN.Open
gConnString = strCNStr
CommonExit:
If Not (objUtility Is Nothing) Then Set objUtility = Nothing
On Error GoTo 0
Exit Sub
ErrorHandler:
If Not (objUtility Is Nothing) Then Set objUtility = Nothing
Err.Raise Err.Number
End Sub
...全文
98 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
womeihuashuo 2004-08-05
  • 打赏
  • 举报
回复
我想也可能是这里出错了,这句本来是用在和SQL sever数据库的连接上的,但我后来把数据库换成Access了,所以我就只把路径改了。但在我的机器上一切运行都OK,换到有些机器上就说数据库连接不到了~
womeihuashuo 2004-08-04
  • 打赏
  • 举报
回复
这句本来就是出错时,ErrorHandler事件响应啊,如果没有错误它是没有影响的啊
of123 2004-08-04
  • 打赏
  • 举报
回复
'On Error GoTo ErrorHandler 注掉这一句。看看调试时的错误提示是什么。
derny 2004-08-04
  • 打赏
  • 举报
回复
what is the error msg?
SoHo_Andy 2004-08-04
  • 打赏
  • 举报
回复
试过了,正常的引用了ADO库后,其它语句就没有错

应该是
Dim objUtility As epUtility 这句产生错误了

我引用自己写的一个类库,没有错程序从
On Error GoTo 0
Exit Sub
正常结束

可能你对 epUtility 的引用有错误,具体要看你的错误提示了
zhysecond 2004-08-04
  • 打赏
  • 举报
回复
将连接字符串改成:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WORK\VendorPrice.mdb;Persist Security Info=True
helanshan 2004-08-04
  • 打赏
  • 举报
回复
把这一句去掉看看:On Error GoTo 0

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧