Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8289031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:24:51+00:00 2026-06-08T12:24:51+00:00

I tried to read out a sample Northwind sqlite database but get an error

  • 0

I tried to read out a sample Northwind sqlite database but get an error on some tables with a datetime. Is this a problem of the database or of my System.Data.SQLite?
The Exception is somethin like: “the string is not a valid DateTime”

http://system.data.sqlite.org/

Of cource I can read out the data by myself with the correct converting of datetime but this is not as performant as reading it out via a simple dt.Load()

        SQLiteCommand dbCommand = myConnector.CreateCommand();
        dbCommand.CommandText = "SELECT * FROM " + tablename;

        SQLiteDataReader executeReader = dbCommand.ExecuteReader(CommandBehavior.SingleResult);
        DataTable dt = new DataTable();
        dt.Load(executeReader); // <-- FormatException

” bei System.DateTimeParse.ParseExactMultiple(String s, String[]
formats, DateTimeFormatInfo dtfi, DateTimeStyles style)\r\n bei
System.DateTime.ParseExact(String s, String[] formats, IFormatProvider
provider, DateTimeStyles style)\r\n bei
System.Data.SQLite.SQLiteConvert.ToDateTime(String dateText,
SQLiteDateFormats format, DateTimeKind kind) in
c:\dev\sqlite\dotnet\System.Data.SQLite\SQLiteConvert.cs:Zeile
322.”

I need a good help to improve the current code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:24:53+00:00Added an answer on June 8, 2026 at 12:24 pm

    Yep, I faced the same problem, and I’ve found a solution.

    First of all you need to know why it happens.

    http://www.sqlite.org/datatype3.html

    **

    SQLite does not have a storage class set aside for storing dates
    and/or times. Instead, the built-in Date And Time Functions of SQLite
    are capable of storing dates and times as TEXT, REAL, or INTEGER
    values:

    **

    TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
    REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar.
    INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC. 
    

    Applications can chose to store dates and times in any of these
    formats and freely convert between formats using the built-in date and
    time functions.

    For more date/time functions you can see this page:
    http://www.sqlite.org/lang_datefunc.html

    SOLUTION:

    Is just use a datetime function to convert your field into a valid .NET datatable format. You can use anyone from the above link, in my case I choose:

    SELECT datetime(field) as field FROM table
    

    TIP 1
    If your query is on a view, and you can’t touch your db, create a different view or something like, you are in a little trouble because the problem is on the db side as I explain before. So the first solution is replace the column of a datatable before load (a little dirty work). Or you can use a Unix stamp on a text field, or any desired timestamp.
    But I think the best solution is create your query on your application from your view:

    SELECT datetime(field) as field FROM view
    

    TIP 2

    You can try also with the SQLite Administrator and play with datetime functions before to check the format.

    TIP 3

    Be aware of your culture globalization also, you can find a problem if you change the culture. Try to your soft work with only one and display it as you want, not as the culture wants. In my country for eg, we use as common this format: dd/MM/yy and is a pain, like the dot on decimal numbers (we use a comma)

    TIP 4

    If you are working with a wizard-defined connection on some report or entity or something like, be sure to check your desired conversion format. For example I use the most common and non problematic way: ISO8601

    SQLite - Add Connection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to read out all existing calendars. I tried the example from here:
I just read Emacs :TODO indicator at left side , and tried it out.
I tried to read a file in a view like this: def foo(request): f
I'm still entangled in error handling problems. After having read and tried lots of
after read this article i tried generate EF model by System.Diagnostics.Process: Process myProcess =
I tried to implement this example to write and read data from internal storage,
I am really getting out of control with this small problem and unable to
This is probably one of those easiest things to deal with but for some
I'm out to write some attached properties as suggested in Pushing read-only GUI properties
I am wondering what would happen if I tried to read files in Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.