创建链接 Oracle 表时出现访问错误

发布于 2024-12-08 00:14:21 字数 657 浏览 3 评论 0原文

我尝试创建一个指向 Oracle 的链接表。为了简单起见,我从手动创建的运行良好的链接表中“窃取”了连接字符串。代码在附录中中断,如下所示。有什么线索吗?谢谢 !

Sub CreaOra()
    Dim db As DAO.Database
    Dim td As DAO.TableDef
    Dim strConn As String
    Set db = CurrentDb
    'connection string copied from a working linked table !'
    strConn = "ODBC;DRIVER={Oracle in OraClient10g_home1};SERVER=ORAJJJ0;UID=xxx;PWD=yyy;DBQ=ORAWOD0;"
    Set td = db.CreateTableDef(Name:="test", SourceTableName:="ORAJJJC01.TBL_MYTBL", Connect:=strConn)
    'next row -> error 3264 No field defined--cannot append TableDef or Index
    db.TableDefs.Append td

    Set td = Nothing
    Set db = Nothing
End Sub

I try to create a linked table pointing to Oracle. To make it simple, I "stole" the connection string from a manually created linked table that is working well. The code breaks in the Append, where indicated below. Any clue ? Thanks !

Sub CreaOra()
    Dim db As DAO.Database
    Dim td As DAO.TableDef
    Dim strConn As String
    Set db = CurrentDb
    'connection string copied from a working linked table !'
    strConn = "ODBC;DRIVER={Oracle in OraClient10g_home1};SERVER=ORAJJJ0;UID=xxx;PWD=yyy;DBQ=ORAWOD0;"
    Set td = db.CreateTableDef(Name:="test", SourceTableName:="ORAJJJC01.TBL_MYTBL", Connect:=strConn)
    'next row -> error 3264 No field defined--cannot append TableDef or Index
    db.TableDefs.Append td

    Set td = Nothing
    Set db = Nothing
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少跟Wǒ拽 2024-12-15 00:14:21

属性参数不能为空。您需要传递 0 或 dbAttachSavePWD ,

  Set td = db.CreateTableDef(Name:="test", Attributes:=0,  SourceTableName:="ORAJJJC01.TBL_MYTBL", Connect:=strConn)

或者如果您不想显式将其设置为 0,也可以这样做

   Set td = db.CreateTableDef("test")
   td.SourceTableName:="ORAJJJC01.TBL_MYTBL"
   td.Connect:=strConn

注意:如果您查看监视窗口中的 td 可以观察到 Connect 和 SourceTableName如果您不传递属性值,则设置为空,但在传递时保留。

The attributes parameter must not be empty. You need to pass 0 or dbAttachSavePWD

  Set td = db.CreateTableDef(Name:="test", Attributes:=0,  SourceTableName:="ORAJJJC01.TBL_MYTBL", Connect:=strConn)

Or you can do this if you don't want to explicitly set it to 0

   Set td = db.CreateTableDef("test")
   td.SourceTableName:="ORAJJJC01.TBL_MYTBL"
   td.Connect:=strConn

Note: If you look at the td in the watch window can observe that the Connect and SourceTableName get set to empty if you don't pass a value for attributes in, but remain when you do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文