Re: Update DataTable (from csv import) data



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.




"Mike D" <MikeD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:12719B89-307C-4FC7-8330-AF77BDF0231D@xxxxxxxxxxxxxxxx
I 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


Actually Date.MinValue is not a value that SQL Server will accept ... SQL Server's min date is something like 1st january 1753

--
http://bytes.thinkersroom.com
.



Relevant Pages

  • =?windows-1252?Q?Re=3A_DBNull_class_=96_something_very_confusing_about_?= =?windows-1252?Q?i
    ... A DBNull object represents the ... But Sql book claims that all fields in a DB must have a value assigned ... as IS NOT NULL, and you do not specify any value for that field, then ... What is the reason for only allowing one instance of DBNull class to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Oracle JDBC error
    ... I know there's no invalid names in the insert because I can insert ... I'm using oracle's ojbdc14 jdbc driver and Java 1.6. ... If so, post the SQL INSERT ... Oracle, when accessed via JDBC and similar libraries, processes the ...
    (comp.databases.oracle.server)
  • RE: [Microsoft][SQLServer 2000 Driver for JDBC]The requested instance is either invalid or not runni
    ... instance is either invalid or not running. ... Produced By Microsoft MimeOLE V6.00.2800.1165 ... I can connect to it using SQL ... | [SQLServer 2000 Driver for JDBC]The requested instance is ...
    (microsoft.public.sqlserver.jdbcdriver)
  • =?windows-1252?Q?DBNull_class_=96_something_very_confusing_about_it?=
    ... I just started learning ADO.NET and Sql ... A DBNull object represents the ... Even when app would simply be just reading from a DB table and upon ... What is the reason for only allowing one instance of DBNull class to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I temporarily limit values in a query field
    ... I am getting an error message: "The expression you entered has a invalid ..or! ... This is the last few lines of the 'old' sql with an attempt to limit the records to values of <500: ... works fine until I try to put limits on it value in the qryClaimDetails query. ...
    (microsoft.public.access.queries)