Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > ADO Data > BatchUpdate pro...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 12 Topic 4229 of 4320
Post > Topic >>

BatchUpdate problem with Vista SP1 and XP SP3

by =?Utf-8?B?RGFtaXIgQXJo?= <Damir Arh@[EMAIL PROTECTED] > May 9, 2008 at 05:16 AM

Since the installation of Service Pack 1 for Windows Vista and Service Pack
3 
for Windows XP, a piece of code is failing which has always worked without

problems before. We've managed to isolate the problem and reproduce it in
a 
small sample.


The sample uses the following database objects:

CREATE TABLE [dbo].[TestTable](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[num] [int] NOT NULL,
CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED 
	(
		[ID] ASC
	) 
)
 
CREATE VIEW TestView
WITH VIEW_METADATA
AS
SELECT ID, num FROM TestTable
 
ALTER TRIGGER TestView_Insert ON TestView
INSTEAD OF INSERT
AS
BEGIN
	SET NOCOUNT ON 
	INSERT INTO TestTable (num) SELECT num FROM inserted
END

Yes, I know the view and its trigger in this case don't make a lot of
sense, 
but in our more complex case this approach drastically simplifies the 
application code.


On this database the following VB6 code is executed:

Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
   
cn.Provider = "SQLOLEDB"
cn.ConnectionString = 
"Server=ServerName;Database=TestDB;Trusted_Connection=No;User 
ID=user;Password=pwd"
Call cn.Open

rs.CursorLocation = adUseClient
Call rs.Open("SELECT * FROM TestView WHERE 1 = 0;", cn, adOpenStatic, 
adLockBatchOptimistic)
Set rs.ActiveConnection = Nothing
Call cn.Close

With rs
	Call .AddNew
	.Fields("ID").Value = -1
	.Fields("num").Value = 1
	Call .Update
End With

With rs
	Call .AddNew
	.Fields("ID").Value = -2
	.Fields("num").Value = 1
	Call .Update
End With

Call cn.Open
Set rs.ActiveConnection = cn
Call rs.UpdateBatch(adAffectAllChapters) ' <- fails here
Set rs.ActiveConnection = Nothing
Call cn.Close


The code fails in the marked line with the error:

Multiple-step OLE DB operation generated errors. Check each OLE DB status 
value, if available. No work was done.


At least two rows have to be added to the table for the error two appear. 
SQL traces show that the first INSERT statement succeeds, but the second
one 
never appears in the trace. This sample manifests the problem on both SQL 
Server 2000 and SQL Server 2005. The production code seems to work fine on

SQL Server 2005 but we haven't managed to find out why the behavior is 
different in this sample.

As I stated previously this works just fine on Windows Vista without SP1
and 
on Windows XP SP2. Something must have changed with the latest service
packs.


It would be really nice to know what exactly is happening here and whether

there is any workaround to make this work. We've already started fixing
our 
code to avoid the need for such views since this really is a pressing
matter 
for our customers which are just starting to deploy the Service Packs.
 




 12 Posts in Topic:
BatchUpdate problem with Vista SP1 and XP SP3
=?Utf-8?B?RGFtaXIgQXJo?=   2008-05-09 05:16:01 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-09 08:35:13 
Re: BatchUpdate problem with Vista SP1 and XP SP3
=?Utf-8?B?RGFtaXIgQXJo?=   2008-05-09 06:55:00 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-09 11:22:34 
Re: BatchUpdate problem with Vista SP1 and XP SP3
=?Utf-8?B?RGFtaXIgQXJo?=   2008-05-09 08:37:01 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-09 12:54:37 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-09 08:39:27 
Re: BatchUpdate problem with Vista SP1 and XP SP3
=?Utf-8?B?RGFtaXIgQXJo?=   2008-05-09 07:04:02 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-12 09:16:03 
Re: BatchUpdate problem with Vista SP1 and XP SP3
=?Utf-8?B?RGFtaXIgQXJo?=   2008-05-13 04:01:02 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-13 07:41:29 
Re: BatchUpdate problem with Vista SP1 and XP SP3
"Bob Barrows [MVP]&q  2008-05-12 09:31:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 15:20:47 CST 2008.