Click to See Complete Forum and Search --> : DataBase Error When Deleting Records.


softweng
May 9th, 2001, 04:04 PM
I have a database with several tables. One form has 8 text boxes and 8 combo boxes bound to a
table in the database through an ADODC control. When I delete records I sometimes get the following error.

-2147217887 Multiple Step Operation Generated Errors. Check Each Status Value.

This only happens sometimes, sometimes it deletes the record fine. I found out that if I do not
execute a certain procedure for filling the combo boxes, this error never occurs. I cannot see any
reason for this. I have included the procedure here to see if anyone can find the problem.
I have searched MSDN and Microsoft.com and have found nothing related to my problem.
All the fields in the table are "Text" with no special formating and they are set to allow 255 characters.
Any Help Is Greatly Appreciated!!!

private Sub FillPartBoxes()
Dim cndata as ADODB.Connection
Dim rsdata as ADODB.Recordset
Dim strSQL as string
Dim strField as string
Dim strData as string
Dim strSelectedPart as string
Dim i as Integer
Dim ii as Integer

on error GoTo ErrHandler

'//Define Connection And Recordset
set cndata = new ADODB.Connection
set rsdata = new ADODB.Recordset

'//Define Query string
Select Case m_Part
Case 0
strSQL = "SELECT * FROM [Springs];"
strField = "Spring"
Case 1
strSQL = "SELECT * FROM [Top Tumbler];"
strField = "Top Tumbler"
Case 2
strSQL = "SELECT * FROM [mid Tumbler];"
strField = "mid Tumbler"
Case 3
strSQL = "SELECT * FROM [Bottom Tumbler];"
strField = "Bottom Tumbler"
Case else
strSQL = "SELECT * FROM [Springs];"
strField = "Spring"
End Select

'//Open Connection
cndata.Open "DSN=NCLRecipe"

'//Open Recordset
rsdata.Open strSQL, cndata, adOpenKeyset, adLockOptimistic

'//Move to First Record
If Not rsdata.BOF then rsdata.MoveFirst

'//Clear Out Part Combo Boxes And Add A Selection for None
i = 0
for i = 0 to 7
cmbParts(i).Clear
cmbParts(i).AddItem "NONE"
next i

'//Fill Part Combo Boxes
i = 0
If (rsdata.RecordCount > 0) then
for i = 1 to rsdata.RecordCount
'//Fill Array Of Boxes
ii = 0
for ii = 0 to 7
strData = rsdata.Fields(strField).Value
cmbParts(ii).AddItem strData
strData = ""
next ii
If Not rsdata.EOF then rsdata.MoveNext
next i
End If

'//Display Database Values
If adodcCharts.Recordset.RecordCount > 0 then
i = 0
for i = 0 to 7
If Not IsNull(adodcCharts.Recordset.Fields("Part #" & (i + 1)).Value) then
strSelectedPart = adodcCharts.Recordset.Fields("Part #" & (i + 1)).Value
cmbParts(i).Text = strSelectedPart
strSelectedPart = ""
End If
next i
End If

'//Close Recordset And Connection
rsdata.Close
cndata.Close

'//set to nothing to Prevent Memory Leaks
set rsdata = nothing
set cndata = nothing

Exit Sub

ErrHandler:
ProccessError ("frmCharts.FillPartBoxes")
End Sub






Kris
Software Engineer
Phoenix,AZ

Cakkie
May 10th, 2001, 01:59 AM
Well, the multiple-step error means (in english) 'something went wrong, i don't know what, find it out yourself'. Ok this isn't very usefull at all, but it means what I just said what it means.

This can be several things, like when you try to add a value to a field which the field cannot hold (eg "Hello" to a field with length 3). Or if the value you try to add just isn't of the given type (like adding 60000 to a field of the type smallint (which is the equivalent of integer)).

These are the things I can think of right now, if I know any other, I'll let you know

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Iouri
May 10th, 2001, 07:11 AM
Run-time error '-2147217887(800040e21)'
Miltiple step OLE DB operation generated errors. Check each OLE DB status value, if available.
No work was done


This error was generated when i was trying to enter null field to the database. When I modified these fields to 0, error stopped being generated.
To catch this error, disable error handler, run the prog end push debug. It will show you the field
where an error occured.

Iouri Boutchkine
iouri@hotsheet.com

softweng
May 10th, 2001, 10:38 AM
I had read all the info in MSDN about null values and incorrect data in the data fields. In my case
this was not the problem I always take extra steps to prevent those problems.
I did find a solution and the error does not happen anymore. I still don't know why it was
happening though. Here is the code I execute before trying to delete a record. It works great now.

'//Store The Current Record Position
RecPos = adodcCharts.Recordset.Bookmark

'//Update And Refresh The Database
'//This is Needed to Prevent The error
'//-2147217887 "Multiple step Operation Generated Errors"
adodcCharts.Recordset.Update
adodcCharts.Refresh

'//Return to The Stored Record Position So It Can Be Deleted
adodcCharts.Recordset.Bookmark = RecPos

'//Delete Current Record
Call DeleteDBRecord(adodcCharts, false)





Kris
Software Engineer
Phoenix,AZ