Checking data before fill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All:

I would like to know how to prevent a dataset from being filled with garbage
data.

Forinstance, if I am importing data from an excel spreadsheet into a
dataadapter and the first column has data with decimal places and I do not
want ANY data to go into the dataset if this condition is true, instead I
want to have a message box appear telling the user what is wrong. How should
I code this? I will do the same sort of thing with other columns. I would
like to prevent any slowness in the fill due to this.

Rachel
 
Hi All:

I would like to know how to prevent a dataset from being filled with
garbage data.

Don't select any garbage data
Forinstance, if I am importing data from an excel spreadsheet into a
dataadapter and the first column has data with decimal places and I do
not want ANY data to go into the dataset if this condition is true,
instead I want to have a message box appear telling the user what is
wrong. How should I code this?

Check the data before filling. For example, you could loop through certain
columns with a datareader to check the data.

Or fill the dataset, then skip certain columns.

Removing a couple of columns usually does not speed up your
dataadpater.fill too much. If you notice that that DA.fill is slow, you
maybe putting too much data into a dataset.
 
Yes, I want to prevent my datagrid from being filled with incorrect
data. So you are saying to fill a datareader with all the data have
my code loop through it and if it is incorrect then throw the error?

Yes.

Or another possiblity is to build your own datatable and put constaints on
the columns - i.e. Integer data only.

Or you can place those contrainst into your database, and therefore you
never have to do these checks in the first place.
 

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

Back
Top