Filtering / comparind datasets

  • Thread starter Zachary Heilman
  • Start date
Z

Zachary Heilman

I'm trying to find the best way to solve a problem.

I have a web program, written in VB, that loads a datafile from disket
and inserts it into a dataset, dsOriginal, which is then bound to a
datagrid for the user to edit and delete incorrect fields. Leaving
out all the details of the editting, when the user hits the submit
button, I want it to compare these datagrid records to a table from a
database to check if the records already exist or have inputted
previously. If they don't exist already, I will input these records
into that table.
The unique identifier of the records is three fields: s_number,
s_date, r_number.

Since there is usually only one file per date, it seems easy enouph to
just query the database for that date, populate datasetFromDataBase
with that info, and then compare the two datasets. If there is any
that are the same, you could create a third dataset with the
duplicates, and delete them from dsOriginal.

Or I could just create a stored procedure that inserts one record at a
time from dsOriginal to the database, and if it fails, I could
populate a new dataset with the failed records to be displayed - after
the inputting is completed. This scares me alot because it gives the
user little control over what goes in and what's left out.

I could always write a stored procedure that just checks if each
record exists against the database and doesn't even do Updating,
allowing the user to decide what they want to do with the bad record
before updating the to the database. But like I said, I could also
just compare dsOriginal to datasetFromDataBase and do something with
one's that match.

Anyone ever come across this scenerio? Any advice as to the best
method for implementing this procedure?


-Thanks, Zack
 
R

Rajesh Patel

may be you want to do like,

when you import from diskette to dataset. create one more bit column depicts
"existance" (shows record exists in the database or not). default is 0.
but, while you import records from diskettet, check at the same time,
whether it's exists through command object and stored procedure with one
output bit parameter (which returns records exists or not). paste the return
result to particular record in the existance column.

then you can give checkbox to "show only existed records" if that is on,
i.e., filter your dataset (dataview) on existance = 1 if checkbox is off
then show all records.

this existance column will help you everytime from importing till the
exporting to database.

HTH

Rajesh Patel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top