What is wrong with the Spare Part Maintenance Screen?

greenspun.com : LUSENET : SmartPart Development : One Thread

(BTW, Category 'New SmartPart Functionality' means that this question is to do with changing the way that SmartPart behaves, and includes 'fixes' to make the system behave as it should have behaved in the first place, not only what might be considered as genuinely 'new' behaviour).

The problem with adding a new spare part is that originally the page http://centrex/Ceetak/cgi-bin/x5AkTY45/sparepartmaintenance/newspare.asp where the new part was added invoked http://centrex/Ceetak/cgi-bin/x5AkTY45/sparepartmaintenance/sparesuccess.asp

which simply gave a list of all possible spares. I have now modified this sparesuccess.asp by passing to it something to identify the spare just added: http://centrex/Ceetak/cgi-bin/x5AkTY45/sparepartmaintenance/sparesuccess.asp?description=test%20spare%20added%20by%20steve

as you will spot, rather than passing the id of the part added it passes the description, and the search in the database to populate the sparesuccess page does a search by description. This is both 1) inefficient and 2) likely to produce multiple spare parts.

The correct fix is to get the stored procedure to return the id of the newly-added spare part in an output parameter, and then pass this to the sparesuccess page through the query string.

Unfortunately the asp code to do the insert is as follows:

stroutcome = objSpare.InsertIt(request.form("mancode"), request.form("desc"), request.form("material"), request.form("manufacturer"), request.form("ECM"), request.form("OCM"), request.form("level"), request.form("type"), request.form("notes"), intSale)^M

i.e. the call to the stored proc is in a specially-written ActiveX object that we cannot modify because we only have the compiled form of it (in the form of a DLL).

Probably the solution in this case is to junk the call to objSpare.InsertIt (and indeed the whole use of sparePartMaintenance Active X object) and call the ADODB object directly, although it would be nice to see the source code of the sparePartMaintenance object, which will be written in Visual Basic, first, just in case any clever transaction processing is taking place.

This really requires some input from Andy and/or Computer Core.

-- Anonymous, February 20, 2002

Answers

we can now get back output parameters from the database, and this means we can retreive the @@insert global that gives the rowid of the last row inserted. This is discussed in more detail under the title of 'how do I do difficult things with the database?'

-- Anonymous, March 04, 2002

Moderation questions? read the FAQ