|
-
Aug 21st, 2008, 09:34 AM
#1
Thread Starter
Frenzied Member
Does Row Exist ???
Hi Peeps,
I have several import routines that imports data from xml files. I currently use this code to see if the row already exists:-
Code:
iRowExists = False
iCurrentRow = -1
For iRowCount = 0 To sqlDSStoreContacts.Tables(0).Rows.Count - 1
If sqlDSXMLStoreContacts.Tables(0).Rows(iRows).Item("SC_ST_STORECODE") = sqlDSStoreContacts.Tables(0).Rows(iRowCount).Item("SC_ST_STORECODE") And _
sqlDSXMLStoreContacts.Tables(0).Rows(iRows).Item("SC_NAME") = sqlDSStoreContacts.Tables(0).Rows(iRowCount).Item("SC_NAME") Then
iRowExists = True
iCurrentRow = iRowCount
Exit For
End If
Next
My problem is that as the table grows the update takes forever. Is there a simpler way of determining if the rows exists you the unique columns as its identifier.
Thanks for any assistance,
Jiggy!
-
Aug 29th, 2008, 01:46 PM
#2
Re: Does Row Exist ???
You might try making a DataView from the DataTable, then using the RowFilter property to narrow your search considerably. I don't think you can filter on more than one column, so you would still be left with a loop looking for one of the two matches.
You might also look at the DataTable.Merge function to see whether any of the various behaviors of that method would get the job done in a single step for you. It would mean creating a datatable (you already have one, it looks like) for the existing table, then making a datatable for the XML and merging the two. The behavior regarding conflicts might not be adequate for you, though.
My usual boring signature: Nothing
 
-
Sep 1st, 2008, 05:31 AM
#3
Thread Starter
Frenzied Member
Re: Does Row Exist ???
Hi Mate,
Thanks for that, in the end I used SQL statement and checked row count. This seemed to speed it up imensely.
Thanks again,
Jiggy!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|