[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.inetserver.asp.db

michael kors handbags br6

Katadedajab

12/25/2013 3:08:00 PM

<a href=http://www.martinet-finewines.com/mk5.html><b&... kors outlet</b></a>I among the more before commented all over the posts which I¡¯d read, digested and (IMHO) had something to learn more about add to going to be the discussion.<a href=http://www.thewizardofart.com/mkstore.html><b&... kors outlet store</b></a>
<a href=http://www.partyservicedallas.com/mk19.html><b&... kors outlet</b></a>In going to be the heavy rain there are always most of these idiots driving their car don't care the pedestrians.all these guys would be the fact really disgusting.<a href=http://www.thewizardofart.com/mkstore.html><... michael kors outlet</b></a>
<a href=http://www.partyservicedallas.com/mk19.html><b&... kors outlet</b></a>Absolutely, there is because one or more post to video named these all a number of us watched throughout the college or university mother said to explore son that life is the fact that like a minumum of one box for example chocolate,all your family members never know what all your family members will get; Anyway,for example a number of us cannot spin out of control aspect but take heart a number of us in the event that butt heads significantly more and get involved with talented for more information on have to settle for element well.<a href=http://www.martinet-finewines.com/mk5.html><b&... kors handbags outlet</b></a>
<a href=http://www.thewizardofart.com/mkstore.html><b&... kors outlet</b></a>It also happens all over the my very own family too.<a href=http://www.martinet-finewines.com/mk5.html><... michael kors handbags</b></a>
4 Answers

AMDRIT

7/3/2007 3:10:00 PM

0

I guess my first question is how did you import the CSV file? I assumed you
used some sort of reader and were creating the datarows as you read each
line, that would be the best place to put your date correction code.

In any event, and assuming that your date field in the datatable is defined
as a string and not as a date.

//assuming you have a datatable object named objTable
foreach datarow dr in objTable.rows
{
if (dr("datefieldname")=="00/00/0000")
{
dr.setNull("datefieldname")
//or
dr("dateFieldName") = date.minvalue // "12:00 AM" --FYI
}
}

if the datefield is a date, then "00/00/0000" should have caused an
exception along the way because it is an invalid date, or the value should
already == date.minvalue or isdbnull(dr("datefieldname"))


"Mike D" <MikeD@discussions.microsoft.com> wrote in message
news:EF67840C-535D-4719-84D0-FF50D5EC004E@microsoft.com...
> First - Thanks for the reply. Second - How would I loop through the
> DataTable to find the rows with the invalid dates? Would I use foreach or
> a
> for loop (if so how would I implement it on a DataTable - row.count)?
> BTW - I am new to C# and .NET so pardon nood questions. I used to be a
> ColdFusion developer for 7 years.
> --
> Regards,
>
> Mike D
>
>
> "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@discussions.microsoft.com> wrote in message
>> news:12719B89-307C-4FC7-8330-AF77BDF0231D@microsoft.com...
>> >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
>>
>>
>>


Mike D

7/3/2007 3:40:00 PM

0

Thanks - I think that will help a lot.

Here is what I used to import the csv file:
string sSqlSelect = "SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft
Text Driver (*.txt; *.csv)};DBQ=C:\;', 'SELECT * from Order_Table.csv')";
SqlDataAdapter daTmpTable = new SqlDataAdapter(sSqlSelect, SqlConn);
DataTable dtTmpTable = new DataTable();
daTmpTable.Fill(dtTmpTable);

So I add your help:
foreach datarow dr in dtTmpTable.rows
{
if (dr("Create Date")=="00/00/0000")
{
dr.setNull("Create Date")
}
if (dr("Close Date")=="00/00/0000")
{
dr.setNull("Create Date")
}

}

Is it possible to bulkcopy the DataTable to a SQL table, or do I need to
loop over the DataTable and insert each row?
--
Regards,

Mike D


"AMDRIT" wrote:

> I guess my first question is how did you import the CSV file? I assumed you
> used some sort of reader and were creating the datarows as you read each
> line, that would be the best place to put your date correction code.
>
> In any event, and assuming that your date field in the datatable is defined
> as a string and not as a date.
>
> //assuming you have a datatable object named objTable
> foreach datarow dr in objTable.rows
> {
> if (dr("datefieldname")=="00/00/0000")
> {
> dr.setNull("datefieldname")
> //or
> dr("dateFieldName") = date.minvalue // "12:00 AM" --FYI
> }
> }
>
> if the datefield is a date, then "00/00/0000" should have caused an
> exception along the way because it is an invalid date, or the value should
> already == date.minvalue or isdbnull(dr("datefieldname"))
>
>
> "Mike D" <MikeD@discussions.microsoft.com> wrote in message
> news:EF67840C-535D-4719-84D0-FF50D5EC004E@microsoft.com...
> > First - Thanks for the reply. Second - How would I loop through the
> > DataTable to find the rows with the invalid dates? Would I use foreach or
> > a
> > for loop (if so how would I implement it on a DataTable - row.count)?
> > BTW - I am new to C# and .NET so pardon nood questions. I used to be a
> > ColdFusion developer for 7 years.
> > --
> > Regards,
> >
> > Mike D
> >
> >
> > "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@discussions.microsoft.com> wrote in message
> >> news:12719B89-307C-4FC7-8330-AF77BDF0231D@microsoft.com...
> >> >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
> >>
> >>
> >>
>
>
>

Rad [Visual C# MVP]

7/3/2007 6:29:00 PM

0

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@discussions.microsoft.com> wrote in message
> news:12719B89-307C-4FC7-8330-AF77BDF0231D@microsoft.com...
>> 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.thinke...

Mike D

7/3/2007 8:36:00 PM

0

I am getting the following error: 'dr' is a 'variable' but is used like a
'method'.
Am I missing something? I know I can't use the Equals method because I need
to identify the column. How do I select the column to compare?

--
Regards,

Mike D


"AMDRIT" wrote:

> I guess my first question is how did you import the CSV file? I assumed you
> used some sort of reader and were creating the datarows as you read each
> line, that would be the best place to put your date correction code.
>
> In any event, and assuming that your date field in the datatable is defined
> as a string and not as a date.
>
> //assuming you have a datatable object named objTable
> foreach datarow dr in objTable.rows
> {
> if (dr("datefieldname")=="00/00/0000")
> {
> dr.setNull("datefieldname")
> //or
> dr("dateFieldName") = date.minvalue // "12:00 AM" --FYI
> }
> }
>
> if the datefield is a date, then "00/00/0000" should have caused an
> exception along the way because it is an invalid date, or the value should
> already == date.minvalue or isdbnull(dr("datefieldname"))
>
>
> "Mike D" <MikeD@discussions.microsoft.com> wrote in message
> news:EF67840C-535D-4719-84D0-FF50D5EC004E@microsoft.com...
> > First - Thanks for the reply. Second - How would I loop through the
> > DataTable to find the rows with the invalid dates? Would I use foreach or
> > a
> > for loop (if so how would I implement it on a DataTable - row.count)?
> > BTW - I am new to C# and .NET so pardon nood questions. I used to be a
> > ColdFusion developer for 7 years.
> > --
> > Regards,
> >
> > Mike D
> >
> >
> > "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@discussions.microsoft.com> wrote in message
> >> news:12719B89-307C-4FC7-8330-AF77BDF0231D@microsoft.com...
> >> >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
> >>
> >>
> >>
>
>
>