one single programmer

I've started doing some independent work on the side. This has opened my eyes to somethings and I plan to write about it as time permits.

Monday, November 20, 2006

Combining datasets

One of the pages that I’m developing required a rather large query.  Since I’m using MS Access as my database I’m limited to the number of characters in the query ( I believe it’s 256.).  So I broke the query apart by the UNIONs that I did with the thought I could combine the datasets after each one.  Well I learned something new.  I tried:

 

For each dr in ds2.tables(0).rows

            Ds.tables(0).rows(0).add(dr)

Next

 

But this threw an error that the row already existed.  I’m not sure of the mechanics of the datasets but to me this made sense.  I did learn that the following works

 

For each dr in dt.rows

            Ds.tables(0).importrow(dr)

Next

 

By assigning the ds2.tables(0) to dt this now worked.  So the disassociation of the datatable from the two dataset seems to allow the add to work.

 

If you know the why’s of above let me know but if you just needed it to work then happy coding!