Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sql and recordset in .net

Hi !

I have a RS.DOQUERY that returns about +/- 50 rows. I would like to put the data in my table row by row. I use this

Do While Not RS.EOF
                        Inv = RS.Fields.Item("RSDOC").Value
                        Bp = RS.Fields.Item("RSCRD").Value
                        Dte = RS.Fields.Item("RSDATE").Value
                        Styl = RS.Fields.Item("RSITM").Value

RS.DOQUERY ("INSERT INTO [@TABLE] .......")

RS.MOVENEXT()
LOOP

When i run my code it gives me the error Invalid Row..

Thanks !!

Alain

replied

Hi Alain

What i spot here is that you use RS as a recordset, before your "while" you must of called it with your +-50 records. Thats good. But then in your loop i see you have another query to insert values, but this will then clear your +-50 records and then when you say rs.movenext it will give that error because the last query (insert query) did not return any results. Rather use a seperate Recordset for the query that return results and another for inserting Alain.

That should solve the problem.

PS: SAP prefers us using there objects to insert into a table instead of using a Query inside a recordset.But this will work!

Hope this helps

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question