Sql and recordset in .net
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..
Louis de Gouveia replied
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