473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bug in ADO, SQL Server and latest OS SPs

Thanks to a posting by fellow MVP Steve Foster

On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect value is returned when an application queries
the identity column value of a newly inserted row in various versions
of SQL Server 2005 and of SQL Server 2000
http://support.microsoft.com/kb/951937

Now I don't *KNOW* that this affects Access but the KB article states
"Applications that use the ActiveX Data Objects (ADO) interface ..."

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Jun 27 '08 #1
8 1966
This (the kb article is not wonderfully informative.

How does an application query "the identity column of a newly inserted
row"? Are we talking @@Identity?
How long is a newly inserted row a newly inserted row?

This occurs, according to the article, when we use a client side cursor.
So let's check:

First, do I qualify?
Microsoft SQL Server Management Studio Express 9.00.2047.00
Microsoft Data Access Components (MDAC) 6.0.6000.16386 (vista_rtm.061101-
2205)
Operating System 6.0.6000
Think so, but who can be sure?

Sub temp()
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Set c = New ADODB.Connection

With c
..CursorLocation = adUseClient
..Open CurrentProject.BaseConnectionString
..Execute ("SET NOCOUNT ON")
End With

Set r = New ADODB.Recordset
With r
..ActiveConnection = c
..CursorLocation = adUseClient
..CursorType = adOpenStatic
..LockType = adLockOptimistic
..Open "SELECT * FROM Schools"

..AddNew Array(1), Array("Test")
Debug.Print .ActiveConnection.Execute("SELECT @@Identity")(0)
‘ 5280 – no bug here

..AddNew Array(1), Array("A Second Test")
Debug.Print .ActiveConnection.Execute("SELECT ID FROM Schools WHERE Name
= 'A Second Test'")(0)
‘ 5281 – no bug here

End With

Whew! My personal VBA code and ASP code and HTA Script may not be
affected.

But can I be sure that bound forms in Access aren’t affected? I don’t
know. Access is an application. One has only to look at Northwinds, the
code produced by Access Wizards, and various KB solutions to realize that
MS is indifferent to good programming and coding practices. So does this
article mean a bound form in an ADP may fail?

I have a couple ADPs in operation but no problem like the one described
has ever been reported to me.

I won’t worry about this right now, but perhaps, someone else will post
code that will demonstrate the bug?
"Tony Toews [MVP]" <tt****@telusplanet.netwrote in
news:g6********************************@4ax.com:
Thanks to a posting by fellow MVP Steve Foster

On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect value is returned when an application queries
the identity column value of a newly inserted row in various versions
of SQL Server 2005 and of SQL Server 2000
http://support.microsoft.com/kb/951937
Jun 27 '08 #2
lyle fairfield <ly******@yah00.cawrote:
>This (the kb article is not wonderfully informative.

How does an application query "the identity column of a newly inserted
row"? Are we talking @@Identity?
I would think so but I don't know.
>How long is a newly inserted row a newly inserted row?
No idea.
>Operating System 6.0.6000
Think so, but who can be sure?
I can't by sure what OS and SP you are running. When I look at
Control Panel >System >General on my system I see Win XP SP2 so
I'm not affected. When I run msinfo32 I see an OS version of
5.1.2600.

I suspect you are running Windows Vista with no SP judging by the
middle 0 thus you wouldn't be affected.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Jun 27 '08 #3
The article KB951937 makes a direct reference to the article KB940569 and
this second one is about this strange hotfix solving (?) the decade long
problem of using @@identity versus scope_identity() when there is a trigger
making insertions on the server side; for example when you are using merge
replication. (And it's far from necessary to use merge replication to
encounter this problem. There are lot and lot of other exemples of this
problem creeping in without using merge replication. I have myself had to
deal with this problem and ADP in the past.)

So, it's quite possible that to have an understanding of KB951937, we must
also read and test KB940569. Personnally, I never applied the hotfix
provided by KB940569 on a WinXP-Sp2 system because this article shows a
total lack of information about what it's doing exactly and its possible
consequences. (And for people have this problem, I would instead suggest the
usual solution of storing the value of @@identity in a local variable at the
beginning of the insert trigger and reset the value of @@identity to this
stored value at the end of the trigger. For an exemple of code, see:
http://groups.google.ca/group/micros...5ce86f0fe13b0a )
..

It's funny to see that at the end of the article 951937, there is a direct
reference about the Microsoft Retail System (RMS) and its famous problem
with WinXP-SP3. This is the (in-)famous problem that has delayed the wide
release of SP3 but has never been explained publicly. I suppose that we can
now see what happened between SP3 and RMS. Another funny thing is to see
that for people with WinXP-Sp3, KB951937 suggests to wait for the next
service pack (SP4?) instead of applying immediately this hotfix.
Personally, I will be very surprised if SP4 ever sees the light of the day;
especially in a timely manner.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)
"Tony Toews [MVP]" <tt****@telusplanet.netwrote in message
news:g6********************************@4ax.com...
Thanks to a posting by fellow MVP Steve Foster

On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect value is returned when an application queries
the identity column value of a newly inserted row in various versions
of SQL Server 2005 and of SQL Server 2000
http://support.microsoft.com/kb/951937

Now I don't *KNOW* that this affects Access but the KB article states
"Applications that use the ActiveX Data Objects (ADO) interface ..."

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

Jun 27 '08 #4
I installed Vista SP1 and ran the code. Again there was no error.

(Note change in MDAC as well as OS)
Microsoft SQL Server Management Studio Express 9.00.2047.00
Microsoft Data Access Components (MDAC) 6.0.6001.18000 (longhorn_rtm.
080118-1840)
Microsoft MSXML 3.0 5.0 6.0
Microsoft Internet Explorer 8.0.6001.17184
Microsoft .NET Framework 2.0.50727.1434
Operating System 6.0.6001

On May 11, 2:33*pm, "Tony Toews [MVP]" <tto...@telusplanet.netwrote:
I suspect you are running Windows Vista with no SP judging by the
middle 0 thus you wouldn't be affected.
Jun 27 '08 #5
"Tony Toews [MVP]" <tt****@telusplanet.netwrote:
>On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect value is returned when an application queries
the identity column value of a newly inserted row in various versions
of SQL Server 2005 and of SQL Server 2000
http://support.microsoft.com/kb/951937
Comments indicate that this problem applies to client side cursors and not server
side cursors. Access apparently uses service side cursors by default. So this may
not be a big deal at all.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Jun 27 '08 #6
I don't think Access uses Server Side Cursors be default.

Try this in an ADP:

Sub temp()
Debug.Print CurrentProject.Connection.CursorLocation = adUseServer
' shows False

' ------------
Debug.Print CurrentProject.Connection.CursorLocation = adUseClient
' shows True
' ------------

Is there something "non-defaultish" about the connection?
Debug.Print CurrentProject.BaseConnectionString

'PROVIDER=SQLOLEDB.1
;INTEGRATED SECURITY=SSPI
;PERSIST SECURITY INFO=FALSE
;INITIAL CATALOG=ESOII
;DATA SOURCE=VOSTRO-DESKTOP\SQLEXPRESS

... Not that jumps out at me.

Of course, Microsoft might say that Access uses Server Side Cursors by
default.

As usual with Microsoft statements that means that there is a fifty
per cent chance that Access uses Server Side Cursors by default.

On May 12, 5:17*pm, "Tony Toews [MVP]" <tto...@telusplanet.netwrote:
"Tony Toews [MVP]" <tto...@telusplanet.netwrote:
On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect value is returned when an application queries
the identity column value of a newly inserted row in various versions
of SQL Server 2005 and of SQL Server 2000
http://support.microsoft.com/kb/951937

Comments indicate that this problem applies to client side cursors and notserver
side cursors. *Access apparently uses service side cursors by default. *So this may
not be a big deal at all.

Tony
--
Tony Toews, Microsoft Access MVP
* *Please respond only in the newsgroups so that others can
read the entire thread of messages.
* *Microsoft Access Links, Hints, Tips & Accounting Systems athttp://www.granite.ab.ca/accsmstr.htm
* *Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
Jun 27 '08 #7
lyle fairfield <ly************@gmail.comwrote:
>I don't think Access uses Server Side Cursors be default.
I have no idea about all this stuff. Sorry.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Jun 27 '08 #8
what is your point Tony?

Just demonstrating a lack of knowledge about the most popular database
in the world?

www.microsoft.com/sql

-Aaron

On May 10, 10:34*pm, "Tony Toews [MVP]" <tto...@telusplanet.net>
wrote:
Thanks to a posting by fellow MVP Steve Foster

On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect value is returned when an application queries
the identity column value of a newly inserted row in various versions
of SQL Server 2005 and of SQL Server 2000http://support.microsoft.com/kb/951937

Now I don't *KNOW* that this affects Access but the KB article states
"Applications that use the ActiveX Data Objects (ADO) interface ..."

Tony
--
Tony Toews, Microsoft Access MVP
* *Please respond only in the newsgroups so that others can
read the entire thread of messages.
* *Microsoft Access Links, Hints, Tips & Accounting Systems athttp://www.granite.ab.ca/accsmstr.htm
* *Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
1
by: B Moor | last post by:
Hello, I am quite bogged down with this problem and would like some tips/help if any one has any. Thanks in advance. The Problem ----------- This system initially seemed quite stable for...
1
by: Darryl Kerkeslager | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/sseoverview.asp SQL Server Express was developed with two distinct uses in mind. The first is as a server product,...
2
by: fniles | last post by:
I have .Net Framework 1.1 on my machine, when I try to create an ASP.NET Web application, it gave me the following error: Visual Studio .NET has detected that the Web server is running ASP.NET...
5
by: Ted | last post by:
I am working on two versions of an application, one of which will be a windows forms application (which will need to be redistributable) and the other will be a web application. I have MS Visual...
6
by: John | last post by:
Hi My app is running on a windows 2000 server with isa 2000 installed. How can it access an external sql server (using its ip) from within the isa 2000 firewall/proxy via code? Thanks ...
1
by: rajalingam | last post by:
Server Error in '/library' Application. -------------------------------------------------------------------------------- Server cannot access application directory 'F:\Library Latest Code\'. The...
7
by: TerpZebra | last post by:
I am having difficulty connecting to SQL Server 2000 on one of our servers via a VB6 program on Vista. I can connect fine to a different server, but it gives me the following error with the server...
4
by: =?Utf-8?B?UnV0Z2VyIEZyYW50emVu?= | last post by:
Hi there, I'm busy trying to get the .net 3 runtime components installed on a fresh instal of windows server 2008 beta 3. I've installed the .net 3 framework by installing the application...
2
by: arijitdas | last post by:
Hi, We have an ASP.NET 2.0 web application where we want to share few user specific data between server and client side code using cookie. We are seeing a very strange behavior that it does not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.