DAO访问 [英] DAO Access

查看:62
本文介绍了DAO访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Word模板,可以访问名为CC10-EndUser.MDB的Access数据库,该数据库也链接到另一个名为CC10-Operations的受密码保护的数据库.MDB。这两个数据库。


在Windows Server 2008 R2 Enterprise下使用Windows 10,此模板已经运行了几年没有问题和以下代码打开数据库。


该组织将使用Windows Server Enterprise Pro实现Windows 10在不久的将来,我们使用Access 2016测试应用程序并收到错误'429':运行时错误'429'Active X组件
无法创建对象。



变量MyPath中的地址是正确的。即使数据库的绝对地址存储在MyPath中,我也会得到同样的错误。



使用Enterprise Pro DAO访问数据库是否有问题?




Dim dbCC10 As DAO.Database


Dim rdCC10 As Recordset


< span style ="font-size:12.0pt; font-family:'Arial',sans-serif"> Dim x,y,z,MyPath,CRLF,PathErrorMsg


  CRLF = Chr(13)& Chr(10)


'  获取路径 - 此表单应与最终用户CC10数据库位于同一文件夹中


MyPath = CurDir& " \cccc database\CC10-EndUser.mdb"



On Error GoTo DBOpenError


'打开数据库以确保它存在


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;设置dbCC10 = OpenDatabase(名称:= MyPath)


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;设置rdCC10 = dbCC10.OpenRecordset(名称:=" cc10")


'得到记录数


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; y = rdCC10.RecordCount


    ;&NBSP;&NBSP;&NBSP;&NBSP; GoTo StrtOps


'错误处理程序


DBOpenError:


'      如果Err = 3024那么


    ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; PathErrorMsg ="打开数据库时出错,请再试一次!" &安培; CRLF& CRLF


      ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; PathErrorMsg = PathErrorMsg& "返回的路径是:" &安培; CRLF& MyPath


      ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; x = MsgBox(PathErrorMsg,vbCritical,"数据库打开错误")


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; ActiveDocument.Close


     ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Application.Quit


     ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;结束


'     &NBSP;&NBSP;结束如果


解决方案

您好
neilfxb,


我可以看到你试图在服务器上自动化Office应用程序。


请注意Office自动化可能无法在服务器上正常工作。


有可能在旧版本它正常工作,但当你转移到其他版本时它停止工作。


你可以尝试访问下面的链接,它将为您提供详细信息。


办公室服务器端自动化的注意事项


您提到错误,"运行时错误"429"Active X组件无法创建对象。"


如果您在上面的链接中看到以下部分,您会发现。



确认了为什么您的自动化代码在测试时无法在服务器端运行的问题。


所以为了解决这个问题,你可以尝试使用Open XML作为支持服务器端自动化的工作。


问候


迪帕克


I have a Word Template that accesses an Access database called CC10-EndUser.MDB, which is also linked to another password-protected database called CC10-Operations.MDB. Both databases.

This template has been working for several years without problem using Windows 10 under Windows Server 2008 R2 Enterprise and the below code to open the database.

The organization is going to implement Windows 10 using Windows Server Enterprise Pro in the near future and we tested the application using Access 2016 and received the error ‘429’ : Run-time error ‘429’ Active X Component Can’t Create Object.

The address in the variable MyPath is correct. Even when the absolute address of the database is stored in MyPath, I get the same error.

Is there a problem with DAO access to the database using Enterprise Pro?

Dim dbCC10 As DAO.Database

Dim rdCC10 As Recordset

Dim x, y, z, MyPath, CRLF, PathErrorMsg

 CRLF = Chr(13) & Chr(10)

'   Get the path - this form should be in the same folder as the End User CC10 database

MyPath = CurDir & "\cc10 database\CC10-EndUser.mdb"

On Error GoTo DBOpenError

' Open the database to make sure it exists

        Set dbCC10 = OpenDatabase(Name:=MyPath)

        Set rdCC10 = dbCC10.OpenRecordset(Name:="cc10")

' get the record count

        y = rdCC10.RecordCount

        GoTo StrtOps

'error handler

DBOpenError:

'       If Err = 3024 Then

            PathErrorMsg = "There was an error opening the database, please try again!" & CRLF & CRLF

            PathErrorMsg = PathErrorMsg & "The path returned was:" & CRLF & MyPath

            x = MsgBox(PathErrorMsg, vbCritical, "Database Open Error")

            ActiveDocument.Close

            Application.Quit

            End

'       End If

解决方案

Hi neilfxb,

I can see that you are trying to automate Office application on server.

please note that Office automations may not work correctly on server.

it is possible that on older version it was working correctly but when you move to other version it stop working.

you can try to visit link below, which will give you detail information.

Considerations for server-side Automation of Office

you had mentioned that you got error, "Run-time error ‘429’ Active X Component Can’t Create Object."

if you see the below part in above link you will find.

which confirms the issue that why your automation code will not work on server side when you test it.

so to solve the issue you can try to use Open XML as an work around which supports server side automation.

Regards

Deepak


这篇关于DAO访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆