Active X ADO RecordSet

I am using ADO 2.7 with Navision 2.6 C/SIDE, and I am wondering how I might evaluate a RecordCount Example: IF rs.RecordCount <>0 THEN Rs.MoveFirst REPEAT Do Something UNTIL rs.EOF I get an error saying on Type conversion not possible because of invalid type variant = integer I try FORMAT(rs.RecordCount) get the same error “text = integer” Try to set a variable called varRecordCount type of Variant: Then: varRecordCount := 0; IF rs.RecordCount <> varRecordCount THEN Rs.MoveFirst REPEAT Do Something UNTIL rs.EOF Get the same error "Type Conversion, blah, blah then it says “variant = variant” What? You can’t compare two Variants to each other???[xx(]

Hi, Try to use EVALUATE function, and store the record count value in an integer variable.

hi, do you really need the recordcount. you can do like this while not rs.EOF do BEGIN do something rs.MoveNext; END; have a look on this topic http://www.navision.net/forum/topic.asp?TOPIC_ID=5368

I had the same problem and my solution is: You must simply assign RecordSet.Recordcount property to an integer variable.

Hi Devin, We are using Nav 2.6f, SQL2000 and ADO 2.6. We use ADO extensively and haven’t seen that problem. Bill Here’s a function we use quite frequently. Sorry about the formatting… Var setup: autRsPartPrc, Automation, ‘Microsoft ActiveX Data Objects 2.6 Library’.Recordset autConn, Automation, ‘Microsoft ActiveX Data Objects 2.6 Library’.Connection **************** GetNAGSListPrice(txtParDetID : Text[20];txtMfID : Text[3];dtPricDate : Date) decReturn : Decimal // Return NAGS PartPrc.Price, autConn is established prior to calling since we use only one connection at a time decReturn := 0; txtSQL := ‘SELECT PRICE, PRICDATE FROM PARTPRC ’ + ’ WHERE PARTID = ’ + CON_SINGLE_QUOTE + txtParDetID + CON_SINGLE_QUOTE + ’ AND MFID = ’ + CON_SINGLE_QUOTE + txtMfID + CON_SINGLE_QUOTE + ’ ORDER BY PRICDATE DESC’; autRsPartPrc.Open(txtSQL, autConn, 1, 1); //adOpenKeyset = 1, adLockReadOnly = 1 IF autRsPartPrc.RecordCount > 0 THEN BEGIN // This is the one we want… autRsPartPrc.MoveFirst; REPEAT dtTemp := autRsPartPrc.Fields().Item(‘PRICDATE’).Value; IF dtTemp <= dtPricDate THEN BEGIN decReturn := autRsPartPrc.Fields().Item(‘PRICE’).Value; autRsPartPrc.MoveLast; END; IF (NOT autRsPartPrc.EOF) THEN BEGIN autRsPartPrc.MoveNext; END; UNTIL autRsPartPrc.EOF; END ELSE BEGIN decReturn := 0; END; autRsPartPrc.Close; // Can be less than zero, but we don’t want to know about it… IF decReturn < 0 THEN BEGIN decReturn := 0; END;

You need to watch integers What are you using the ADO in? If it is Visual Basic then the integer has to be Long if your query will return a large number of records.