in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Problem with SQLiteDataReader. Cannot display value Datetime field data type

Last post 12-11-2006 6:15 PM by gintak. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 12-05-2006 11:57 PM

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Problem with SQLiteDataReader. Cannot display value Datetime field data type

    Hi All.  I'm new to SQLite. Please help poor me... I'm not able to retrieve value from a dateTime field using

    SQLiteDataReader  namespace 'item'. everytime gives me error. Sample code below. TQ.

    Dim v_cmd As SQLiteCommand 'DbCommand

    Dim v_reader As SQLiteDataReader 'DbDataReader

    v_cmd = conn.CreateCommand

    v_cmd.CommandText = "SELECT dateTime_field FROM myTable_T"

    Try

    v_reader = v_cmd.ExecuteReader

    Catch exp As Exception

    Exit Sub

    End Try

    If v_reader.HasRows = True Then

    v_reader.Read()

    MsgBox(v_reader.Item("dateTime_field").ToString)    ' error display here

    v_reader.Close()

    End If

  • 12-06-2006 12:27 AM In reply to

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    How are your dates and times formatted in your database?  What is the table definition?  What error exactly are you getting?

    Robert

     

  • 12-06-2006 6:29 PM In reply to

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    Sorry Robert,

    Here are the details:

    Column Type = datetime

    format = dd/mm/yyyy hh:mm:ss              example = '29/09/2006 10:10:05'

    I got this long error message:

    at System.DateTimeParse.ParseExactMultiple()

    at System.DateTime.ParseExact()

    at System.Data.SQLite.SQLiteConvert.ToDateTime()

    at System.Data.SQLite.SQLiteConvert.ToDateTime()

    at System.Data.SQLite.SQLite3.GetDateTime()

    at System.Data.SQLite.SQLite3.GetValue()

    at System.Data.SQLite.SQLiteDataReader.GetValue()

    at System.Data.SQLite.SQLiteDataReader.get_Item()

    at DeviceApplication1.Form1.read_data()

    at DeviceApplication1.Form1.cmdSelect_Click()

    at System.Windows.Forms.Control.OnClick()

    at System.Windows.Forms.Button.OnClick()

    at System.Windows.Forms.ButtonBase.WnProc()

    at System.Windows.Forms.Control._InternalWnProc()

    at Microsoft.AGL.Forms.EVL.EnterMainLoop()

    at System.Windows.Forms.Application.Run()

    at DeviceApplication1.Form1.Main()

     

    Thanks again.

     

  • 12-06-2006 6:38 PM In reply to

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    Sorry forgot,

    Table definition like

    CREATE TABLE myTable_T(dateTime_field datetime)

     

  • 12-06-2006 8:05 PM In reply to

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    I see.  Your dates are not stored in any ISO8601 format, so SQLite cannot parse them.  They need to be in a format such as:

    yyyy/mm/dd hh:mm:ss

     

  • 12-07-2006 12:19 AM In reply to

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    hymmmm..

    I tried to insert the datetime field according to 'yyyy/mm/dd hh:mm:ss' format

    example '2006/10/10 10:10:10'. Works fine.  But when i query the same field again, the same error

    displayed exactly like my previous post.  I'm blurr....

  • 12-07-2006 7:50 AM In reply to

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    Send me the db and some sample code, robert at blackcastlesoft dot com

    Robert

     

  • 12-07-2006 6:53 PM In reply to

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    I've mailed my sample code to robert at blackcastlesoft dot com.  Have fun.
  • 12-11-2006 1:50 AM In reply to

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    hi Robert,

    Have you received my mail!   Hope you can lend me a hand, please....

     

  • 12-11-2006 7:31 AM In reply to

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    No, I haven't received it yet ... send it again.

    Robert

     

  • 12-11-2006 6:15 PM In reply to

    • gintak
    • Top 150 Contributor
    • Joined on 12-05-2006
    • Posts 7

    Re: Problem with SQLiteDataReader. Cannot display value Datetime field data type

    Sent. 5 minutes ago. to robert@blackcastlesoft.com.
Page 1 of 1 (11 items)
Powered by Community Server (Commercial Edition), by Telligent Systems