使用代码刷新ODBC链接SQL SEVER表

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
 在用MDB与SQL SEVER2000链接时,有时需要刷新链接表,通过以下代码可以达到目的,此主题的解决参考了网友cwang的代码,并得到了微软工程师Billy Yao 的热心帮助,在此致谢!

    Function relink()
                Dim db As Database
                Dim tbl As TableDef
                Dim a As String
                Dim b As String
                Dim d As String
               
                a = sa'数据库用户
                b = abc'数据库口令
                d = abcde'数据库名称
                Set db = CurrentDb
                For Each tbl In db.TableDefs
                    If tbl.Attributes = 536870912 Then
                        tbl.Connect = FILEDSN=d:/demo/steel.dsn;UID= & a & ;PWD=
            & b & ;WSID=;DATABASE= & d & ;Network=DBMSSOCN
             '
                        tbl.Attributes = dbAttachSavePWD
                        tbl.RefreshLink
                    End If
                Next
            End Function
            附上微软工程师Billy Yao的解答说明:
            根据您的描述,我对您的问题解答如下:
            1. DSN=gnts 中gnts是系统DSN的文件名。
            2. UID是用户名,并且它的值由变量a的值决定。PWD是密码,并且它的值由变量b的值决定。
            3. WSID 是指工作站的ID号 (Workstation ID)。变量d的值表示数据库的名称。 Network=DBMSSOCN
            指TCP/IP所使用的网络库(Network Library)。
            关于ODBC DSN Connection String的更多信息,您可参见以下这些文章:
            http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSN.htm
            http://support.microsoft.com/default.aspx?scid=kb;EN-US;260249 <script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: 数据库
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭