Re: Update DataTable (from csv import) data
- From: "Rad [Visual C# MVP]" <rad@xxxxxxxxxx>
- Date: Tue, 03 Jul 2007 21:29:23 +0300
AMDRIT wrote:
You will have to allow the date field to allow null values or set the date to some constant arbitrary value (i.e. date.minvalue). When setting the dates in the datatable to null all you need to do is either not set the value or datarow.setnull("datefieldname") if you are going to allow nulls or set the value to some arbitrary value datarow("datefieldname") = date.minvalue. Your data adapter will know what to do if you accomodate as I have suggested.Actually Date.MinValue is not a value that SQL Server will accept ... SQL Server's min date is something like 1st january 1753
"Mike D" <MikeD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:12719B89-307C-4FC7-8330-AF77BDF0231D@xxxxxxxxxxxxxxxxI have finally been able to import a csv file into a DataTable. The data has
invalid dates which won't insert into the SQL table I have. So I have been
trying to figure out how to DBNull the invalid dates while still in the
DataTable but I don't understand C# (or .NET) enough to know what or how to
do it. There are two date fields which have '00/00/0000' and may have
'fat-fingered' dates too, so I basically need to loop over the DataTable
row-by-row and perform a check of the data in the two fields (I have an
isDate(object obj) method). If the data is invalid then DBNull the value.
So far I have created a SqlDataAdpater and a DataTable and now I hit the
brick wall as to what to do next. The DataTable has 19 columns and is
usually over 30,000 rows. Any ideas, help, or guidance?
--
Regards,
Mike D
--
http://bytes.thinkersroom.com
.
- References:
- Re: Update DataTable (from csv import) data
- From: AMDRIT
- Re: Update DataTable (from csv import) data
- Prev by Date: Re: @@identity
- Next by Date: Trouble connecting to Oracle from C#
- Previous by thread: Re: Update DataTable (from csv import) data
- Next by thread: Trouble connecting to Oracle from C#
- Index(es):
Relevant Pages
|