Algorithm for faster search in DataTable

  • Thread starter Thread starter Rathtap
  • Start date Start date
R

Rathtap

I read claims from a file into a DataTable and DataRow and then use
the data adapter's Update method to push those claims into the
database.
I import a few thousand claims at a time and before adding a claim to
the DataTable I need to check if a claim with the same pk has already
been added to the DataTable. If not I run a stored Proc to do the same
check in the database. Pseudocode looks loke this:
-----------------------------------------------
for(int i = 0;i< tblClaims.Rows.Count;i++)
{
//look for claim_id and others(PK is 6 fields)

//if found return
}
//If not found look in the database
 
Rathtap said:
I read claims from a file into a DataTable and DataRow and then use
the data adapter's Update method to push those claims into the
database.
I import a few thousand claims at a time and before adding a claim to
the DataTable I need to check if a claim with the same pk has already
been added to the DataTable. If not I run a stored Proc to do the same
check in the database. Pseudocode looks loke this:
-----------------------------------------------
for(int i = 0;i< tblClaims.Rows.Count;i++)
{
//look for claim_id and others(PK is 6 fields)

//if found return
}
//If not found look in the database

If you use a DataView with a RowFilter which looks for things, I
believe it will do a fair amount of work to make things quicker if
you've specified the primary key in the schema.
 
Back
Top