创建链接 Oracle 表时出现访问错误
我尝试创建一个指向 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
属性参数不能为空。您需要传递 0 或 dbAttachSavePWD ,
或者如果您不想显式将其设置为 0,也可以这样做
注意:如果您查看监视窗口中的 td 可以观察到 Connect 和 SourceTableName如果您不传递属性值,则设置为空,但在传递时保留。
The attributes parameter must not be empty. You need to pass 0 or
dbAttachSavePWD
Or you can do this if you don't want to explicitly set it to 0
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.