BUG: Distributed SQL Update, Jet Provider may not Return ErrorsID: Q201905
|
When using a SQL Server 7.0 distributed query, with the Jet 4.0 OLE DB Provider to update a row in a Microsoft Access .mdb file, the update may fail and you will see an error similar to the following:
However, the Jet provider returns more details on the error when the same update is used outside a SQL Server distributed query.OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
When problems occur using a distributed query and no error information is available, simplify the query to see if there is a problem with a specific part of the the distributed query.
Microsoft has confirmed this to be a bug in Microsoft SQL Server 7.0.
Microsoft SQL Server version 7.0 provides the ability to perform queries against OLE DB providers. This is done by using the OpenQuery or OpenRowset Transact-SQL functions or by using a query with four part names including a linked-sever name.
You can perform a SQL Server distributed update through the Jet OLEDB provider. For example:
UPDATE Access...shippers
SET CompanyName='Speedy Express'
WHERE CompanyName='Speedy Expres'
'Access' is a linked server that points to the Microsoft Access sample NWind.mdb file.
However, the Jet provider may not return details on the cause of the error when an Update query fails.
EXEC sp_addlinkedserver
'Access',
'',
'Microsoft.Jet.OLEDB.4.0',
'e:\VS98\VB98\nwind.mdb',
NULL,
NULL
go
sp_addlinkedsrvlogin 'Access', 'FALSE', NULL, 'Admin', Null
go
update Access...orders set shipvia=10 where shipvia=1
The Update statement fails with the following error:
If you run the same update statement directly through the Jet OLEDB provider in an ActiveX Data Objects ADO application, it will give the precise error message regarding why the update failed:
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
Following is a Visual Basic snippet of code that will produce error details:You cannot add or change a record because a related record is required in shippers table.
Dim cn As ADODB.Connection, rs As ADODB.Recordset, I As Long
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "e:\vs98\vb98\nwind.mdb"
' The following gives an error "You cannot add or change a record
' because a related record is required in shippers table:
cn.Execute "Update orders set shipvia=10 where shipvia=1"
SQL 7.0 Books Online; search on: "sp_addlinkedserver"; topics: "OpenQuery"; "OpenRowset".
Additional query words: kbDSupport kbcode
Keywords : kbole kbDatabase kbOLEDB kbProvider kbSQLServ
Version : WINDOWS:4.0; winnt:7.0
Platform : WINDOWS winnt
Issue type : kbbug
Last Reviewed: January 30, 1999