How to make a passthrough / passthru query editable?

后端 未结 4 1282
夕颜
夕颜 2020-12-07 01:45

In the Microsoft Access 2007 with an SQL Server Backend, we usually take a linked table from the SQL Server as Form.RecordSource of an editable form for a single table data

4条回答
  •  醉话见心
    2020-12-07 02:37

    There is an easier non well documented way to open any SQL Server Select Statement (a table, a view or a sql-select with many joined tables) in a MsAccess query window and be editable/updatable:

    Open an Access query window and enter your SQL Statement. Replace the table name(s) with the full ODBC string to the SQL Server inside square brackets, following by a dot and the schema and table name like in the following example:

    Before:

    SELECT SOH.SalesOrderID, SOH.OrderDate
    FROM   Sales.SalesOrderHeader as SOH 
    

    After:

    SELECT SOH.SalesOrderID, SOH.OrderDate
    FROM   [ODBC;Driver=SQL Server;Server=myServer;Database=AdventureWorks2012;Trusted_Connection=Yes;MarsConn=yes;].Sales.SalesOrderHeader as SOH 
    

    The Query is now updatable:

    Remarks:

    • Not every SQL Statement makes a table or view updatable. For limitations and restrictions see the section 'Updatable Views' in CREATE VIEW (Transact-SQL) (https://msdn.microsoft.com/en-us/library/ms187956.aspx).
    • The underlying table you want to be updatable in Access must have a timestamp or RowVersion column.

提交回复
热议问题