设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 744|回复: 8
打印 上一主题 下一主题

怎么样自动链接ODBC

[复制链接]
跳转到指定楼层
1#
发表于 2003-4-17 01:43:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问怎么自动链接ODBC?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2003-4-17 05:13:00 | 只看该作者
关注
谁能给举一个例子
3#
发表于 2003-4-17 05:36:00 | 只看该作者
请用搜索功能,我以前好象看到有网友发过类似的帖子,好象是zhuyiwen回答的。
4#
 楼主| 发表于 2003-4-17 06:24:00 | 只看该作者
zhuyiwen版主是回答了,可是我看不懂是什么意思,本人英文实在是不行,可否翻一下
http://www.mvps.org/access/tables/tbl0010.htm
5#
发表于 2003-4-17 07:07:00 | 只看该作者
生平我最恨洋文,以下是我乱译一气,请英语好的网友帮忙完善一下:

Personally, I find the manual steps required to link to an ODBC table rather annoying.  If you feel the same way, here's how to automate the whole process.

    I'd suggest creating a table with three fields,
手动链接ODBC烦死了,如果你有同感,这里将告诉您如何自动连接ODBC。建议创建一个表,表中有三个字段。

LocalTableName -- The name of the ODBC table as it appears in the Database window.
客户端表
ConnectString -- The complete connect string to the ODBC Table. (Can be viewed by
连接表
?CurrentDB.TableDefs("SomeODBCTable").Connect

SourceTable -- The actual name of the ODBC table in the Data source. May be the same as Local Table Name.
服务器表--要求服务器中的表与客户端数据库中的表名一致
Store this information for all ODBC tables in this table (referred to as tblReconnectODBC in code).  The benefit is that when this code is run in a new mdb, it re-creates a tabledef for each entry in this table if no ODBC Links are found in the database.

    If you want, you can also add RegisterDatabase method to this code when the DSNs are not found in registry. I, unfortunately, haven't had any luck with it since I'm dealing with Oracle.


'****************** Code Start *********************>
' This code was originally written by Dev Ashish.
'本代码的原作者为dew ashish
' It is not to be altered or distributed,

' except as part of an application.
'未经允许不得更改或分发
' You are free to use it in any application,
' provided the copyright notice is left unchanged.

' Code Courtesy of
' Dev Ashish
''您可无偿使用但请在代码中注明原作者:Dev Ashish
Option Compare Database
Option Explicit

Private Type tODBCInfo
    strTableName As String
    strNewName As String
    strConnectString As String
    strSourceTable As String
End Type

'Contains all info for tables
Private mastODBCInfo() As tODBCInfo

'*** Registry stuff
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const HKEY_PERFORMANCE_DATA = &H80000004
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_DYN_DATA = &H80000006
Private Const STANDARD_RIGHTS_READ = &H20000
Private Const KEY_QUERY_VALUE = &H1&
Private Const KEY_ENUMERATE_SUB_KEYS = &H8&
Private Const KEY_NOTIFY = &H10&
Private Const Synchronize = &H100000
Private Const KEY_READ = ((STANDARD_RIGHTS_READ Or _
                        KEY_QUERY_VALUE Or _
                        KEY_ENUMERATE_SUB_KEYS Or _
                        KEY_NOTIFY) And _
                        (Not Synchronize))
Private Const MAXLEN = 256
Private Const ERROR_SUCCESS = &H0&
Const REG_NONE = 0
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_DWORD_LITTLE_ENDIAN = 4
Const REG_DWORD_BIG_ENDIAN = 5
Const REG_LINK = 6
Const REG_MULTI_SZ = 7
Const REG_RESOURCE_LIST = 8

Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type

Private Declare Function apiRegOpenKeyEx Lib "advapi32.dll" _
        Alias "RegOpenKeyExA" _
        (ByVal hKey As Long, _
        ByVal lpSubKey As String, _
        ByVal ulOptions As Long, _
        ByVal samDesired As Long, _
        ByRef phkResult As Long) _
        As Long

Private Declare Function apiRegCloseKey Lib "advapi32.dll" _
        Alias "RegCloseKey" _
        (ByVal hKey As Long) _
        As Long

Private Declare Function apiRegQueryValueEx Lib "advapi32.dll" _
        Alias "RegQueryValueExA" _
        (ByVal hKey As Long, _
        ByVal lpValueName As String, _
        ByVal lpReserved As Long, _
        ByRef lpType As Long, _
        lpData As Any, _
        ByRef lpcbData As Long) _
        As Long

Private Declare Function apiRegQueryInfoKey Lib "advapi32.dll" _
        Alias "RegQueryInfoKeyA" _
        (ByVal hKey As Long, _
        ByVal lpClass As String, _
        ByRef lpcbClass As Long, _
        ByVal lpReserved As Long, _
6#
发表于 2003-4-17 07:22:00 | 只看该作者
别告诉我他注册odbc用写注册表的方法阿!????
我会疯掉的,呵呵
7#
 楼主| 发表于 2003-4-17 16:58:00 | 只看该作者
以下是引用cg1在2003-4-16 23:21:35的发言:
别告诉我他注册odbc用写注册表的方法阿!????
我会疯掉的,呵呵

不会吧,真的吗?
8#
 楼主| 发表于 2003-4-17 17:08:00 | 只看该作者
能否做个具体引用的例子
9#
 楼主| 发表于 2003-4-17 17:10:00 | 只看该作者
对了还有一个问题,怎么使SQL远程应用链接怎么实现功能呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-9-23 05:22 , Processed in 0.194646 second(s), 32 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表