You need to find out what the Datatype is of the "CreateDate" column. If it
is datetime, then you need to cast it to
(Datetime) dtTmpTable.Rows[i]["Create Date"]
otherwise, you are comparing a string to an object, which will fail.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com
I believe all the columns are of datatype string as I did a Select From
Openrowset from a csv file. The code I am using completes without error but
it doesn't find any rows with the string "00/00/0000" either. If I do a
Select() from a DataRow then I get around 12,000 rows for one column and
around 6,000 rows for the other column. But when I try to update the
Datatable I update the first 12,000/6,000 rows of the DataTable and not the
rows that need to be updated. I don't know how to convert the edited DataRow
results back to the DataTable.

Signature
Regards,
Mike D
Coding in C# since Feb 2007
> You need to find out what the Datatype is of the "CreateDate" column. If it
> is datetime, then you need to cast it to
[quoted text clipped - 21 lines]
> > }
> > dtTmpTable.AcceptChanges();
Mike D - 09 Jul 2007 18:32 GMT
I figured out how to do it.
DateTime dtTemp;
for (int i = 0; i < dtTmpTable.Rows.Count; i++)
{
try
{
dtTemp = DateTime.Parse(dtTmpTable.Rows[i]["Create
Date"].ToString());
if (dtTemp < DateTime.Parse("1990-01-01") || dtTemp >
DateTime.Parse("2099-12-31"))
{
dtTmpTable.Rows[i]["Create Date"] = DBNull.Value;
}
}
catch
{
dtTmpTable.Rows[i]["Create Date"] = DBNull.Value;
}
}
dtTmpTable.AcceptChanges();
Now I have to do is figure out how to take the DataTable and insert it into
the SQL table.

Signature
Regards,
Mike D
Coding in C# since Feb 2007
> I believe all the columns are of datatype string as I did a Select From
> Openrowset from a csv file. The code I am using completes without error but
[quoted text clipped - 30 lines]
> > > }
> > > dtTmpTable.AcceptChanges();