How to restore ODBC connection after failure in MS Access

前端 未结 2 2023
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 00:28

There is a MS Access application with tables on MS SQL Server linked through ODBC. When connection is lost i receive ODBC error 3146. After connection is restored physically i s

2条回答
  •  走了就别回头了
    2021-01-22 00:52

    I think all you need to do is refresh the table links. Are you asking how to relink the tables programmatically? Have you tried refreshing the links after being disconnnected and verified that it solves the problem? Refreshing the link in VBA would be something like

    Dim db as Database
    Set db = Currentdb()
    db.TablesDefs(1).RefreshLink
    

    You may have to loop thru the tables to get the index I am not sure if it will take the table name but you could try it that way first.

提交回复
热议问题