Why does linked view give different results from MS Access vs SQL Manager?

前端 未结 2 2040
轮回少年
轮回少年 2021-01-18 23:12

I created a view on SQL Server 2000 and linked the view to my Access 2007 database via ODBC. Opening the view from Access showed what looked like a duplicate value. I update

相关标签:
2条回答
  • 2021-01-18 23:55

    When you create an ODBC link in Access to a SQL Server table or view, Access stores meta information about that SQL Server data source. If you later change the SQL Server table structure or view definition, Access' cached information does not get reliably updated to match ... even if you "refresh" the link. It's safer to delete the link and re-create it anew to guarantee that Access' cached information is consistent with the revised data source.

    Seems you discovered this fact with Cristian's help. I'm emphasizing this point for the benefit of other readers. This seems to be a fairly common gotcha, but is easily avoided when you understand what's going on under the covers.

    0 讨论(0)
  • 2021-01-18 23:57

    You don't need all the 8 tables linked in Access...the view is enough, Access doesn't need to know about the underlying tables.

    I think you have a different problem, I experienced similar issues like yours as well.
    When I link a SQL Server view in Access via ODBC, a window pops up that wants me to select a unique identifier (read: primary key) from the columns in the view:

    "select unique identifier" window

    If I don't select anything (or some wrong columns, which do not identify a unique record), Access screws up the displayed data like in your example.
    Apparently Access is not able to display the view correctly without a unique identifier.

    Solution for your problem:
    As I understand your view, the id is unique, right?
    If yes, just delete the view, re-link it via ODBC, and when the "select unique identifier" window pops up, you need to select the id column.

    0 讨论(0)
提交回复
热议问题