DSN less ODBC Connection iSeries

时间:2014-03-26 16:38:43

标签: vba db2 odbc ms-access-2010 ibm-midrange

我用当前的项目打了一个墙。我有一个Access 2010 32位数据库,通过ODBC链接到IBM iSeries。此应用程序运行各种检查并需要更新表。当我在具有系统DSN连接的PC上使用它时,它工作正常。但是,这将部署到用户,并且我有指令在VBA中硬编码连接。

我的数据库为6个表,到目前为止,我在AutoExec模块中有以下内容:

(我已经X'了解任何敏感信息)

==================================

Option Compare Database
Option Explicit
Type TableDetails
TableName As String
SourceTableName As String
Attributes As Long
IndexSQL As String
Description As Variant
End Type


Public Function IBM()
Dim cn As New ADODB.Connection
Dim MinConStr As String
Dim S As String
Dim uid As String
Dim pwd As String

'You can use a full or partial connect string.

'Minimum connect string requires DRIVER and SYSTEM keywords.
'All other values default to the same value as a new data source.
'MinConStr = "DRIVER={iSeries Access ODBC Driver};SYSTEM=X.X.X.X;"
'cn.Open MinConStr
'cn.Close

'Full connect string
'NOTE: Connect strings should be verified after each CA version upgrade
S = "DRIVER=iSeries Access ODBC Driver;"
S = S & "MGDSN = 0;"
S = S & "SEARCHPATTERN = 1;"
S = S & "ALLOWUNSCHAR = 0;"
S = S & "COMPRESSION = 0;"
S = S & "MAXFIELDLEN = 32;"
S = S & "SIGNON = 3;"
S = S & "SSL = 2;"
S = S & "SORTWEIGHT = 0;"
S = S & "LANGUAGEID = ENU;"
S = S & "DFTPKGLIB = QGPL;"
S = S & "PREFETCH = 0;"
S = S & "SORTTYPE = 0;"
S = S & "CONNTYPE = 0;"
S = S & "REMARKS = 0;"
S = S & "LIBVIEW = 0;"
S = S & "LAZYCLOSE = 1;"
S = S & "TRANSLATE = 0;"
S = S & "SCROLLABLE = 0;"
S = S & "BLOCKSIZE = 32;"
S = S & "RECBLOCK = 2;"
S = S & "XDYNAMIC = 1;"
S = S & "DEC = 0;"
S = S & "TSP = 0;"
S = S & "TFT = 0;"
S = S & "DSP = 1;"
S = S & "DFT = 5;"
S = S & "NAM = 0;"
S = S & "DBQ = DDILLING;"
S = S & "CMT = 0;"
S = S & "System = x.x.x.x;"

'UID and PWD can be passed in the connect string or on the open. This example passes them on the open.
S = S & "UID=xxxxxx;" 'optional
S = S & "PWD=xxxxxx;" 'optional

cn.Open S, uid, pwd
'cn.Close

'Or build and distribute a file dsn with the application. Use ODBC administrator to create the file dsn text file.
'cn.Open "File Name=C:\mydsn.dsn"
'cn.Close


'Another option is to build the datasource in your install
' - Use the ODBC Installer C APIs. VB Example (mnuCreateDSN_Click) is shown below.
' - Use the DAO DBEngine's RegisterDatabase method
' - Create the registry key (not recommended)

For Each varLinkedTableName In colCurrentTables
DoCmd.TransferDatabase acLink, "ODBC Database"
strConnectionString , acTable, varLinkedTableName, varLinkedTableName
Next

End Function

==================================

当我编译但收到消息时

未定义变量

varLinkedTableName在for each语句中突出显示。这是否意味着缺少参考?

另外,我甚至不确定上述是否是达到我想要的正确方法?是否最好先使用系统DSN链接表,然后使用VBA手动刷新它们?

非常感谢任何帮助。

此致

迈克尔

0 个答案:

没有答案