Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / August 2004



Tip: Looking for answers? Try searching our database.

Key column insufficient Error after upgrading to SQL 2000

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ktaro - 27 Aug 2004 03:37 GMT
After upgrading to SQL Server 2000 SP3, our VB app is encountering a really
nasty bug.

The error is:
"Key column information is insufficient or incorrect. Too many rows were
affected by update."

I use VB6 (SP5) and ADO 2.7

1) First I open a disconnected recordset.  (RecID is a Primary key,
CustomerID is a Foreign key)
   Dim Rs As New ADODB.Recordset
   Rs.CursorLocation = adUseClient
   Rs.Open "SELECT RecID, CustomerID, Street, CurrentFlag FROM Address
WHERE OldFlag = 'Y' AND CustomerID = 10", Cn, adOpenStatic,
adLockBatchOptimistic
   Set Rs.ActiveConnection = Nothing   ' Disconnected recordset

2) If a customer has 3 addresses with OldFlag = 'Y', Rs will have 3 records.
Let the user scroll to ONE record and click chkDelete Checkboxes.

3) When user clicks chkDelete in the interface, scroll to the record and
delete.
    .MoveFirst
    Do While Not .EOF
         If !RecID= SelectedID Then
            blnFound = True
            Exit Do
       End If
         .MoveNext
    Loop
    if blnFound then Rs.Delete

4) When user hits Save button, do
    Set recAddress.ActiveConnection = Cn
    recAddress.UpdateBatch     ' Results in ERROR

UpdateBatch will result in Err.Number = -2147467259
"Key column information is insufficient or incorrect. Too many rows were
affected by update."

If I query the table at this point, ALL the addresses that belonged to
CustomerID = 10 are deleted, even the ones with OldFlag = 'N' !!

The above code used to work fine when we had SQL Server 7.0.

Has anyone encountered this problem?
Does anybody know a solution/work around?
I'd really appreciate it.

Ktaro
Val Mazur - 31 Aug 2004 01:46 GMT
Hi,

Do you have a primary key defined for your Address table? If not, then you
need to create it to be able to solve this issue. Also split declaration and
instantiation of the recordset into two different statements

Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset

Signature

Val Mazur
Microsoft MVP

> After upgrading to SQL Server 2000 SP3, our VB app is encountering a
> really
[quoted text clipped - 49 lines]
>
> Ktaro
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.