• lonhanner (12/27/2012)


    I have a column called "UP_DATE". When the code below trys to read "UP_DATE" I get the following

    riders.UP_DATE = CDate(reader("UP_DATE").ToString)

    error. Conversion from string "" to type date is not valid. It looks as its tring to convert time. here is the data I get. riders.UP_DATE #12:00:00 AM#. Anyone have a solution to how to fix this column

    .

    When i query the data in SQL server manegement it displays the date fine. I have other date fields and they convert ok.

    What is this code and what does #12:00:00 AM# mean? That looks like data from Access or something.

    The error message is however pretty self explanatory. Whatever is reading your table it is getting an empty string in reader("UP_DATE") which can't be cast to a datetime object in many languages. t-sql will convert an empty string to 1/1/1900 but .NET will throw an exception when parsing a date from an empty string.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/