Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Location
    Londrina-Pr-Brazil
    Posts
    3

    Unhappy Unanswered: Date Field Problem

    I had a problem when ive tryed to update a date field.
    The error message is
    "[Mysql][Odbc 3.51 Driver][mysqld-3.23.51] You hav an error in your syntax near '00-2001' AND 'avteffective'='01/11/1983' AND 'avtrecurring'='3' AND.... At line 1"
    I version mysql 4, the message is "unable to locate the row for update..."
    Ive tryed to use Date and DateTime data type, and it dont work...
    This happen only in when the register is edited...


    The code is:

    Public Sub Update()
    For n = 1 To cFields.Count
    If DSet.Fields(n - 1).Type = adDBDate Or DSet.Fields(n - 1).Type = adDBTimeStamp Or DSet.Fields(n - 1).Type = 200 Then
    If Not IsDate(cFields.Item(n)) Then
    GoTo fora
    Else
    DSet.Fields(n - 1) = CDate(cFields.Item(n)) '"aaaa-mm-dd")
    End If
    End If

    DSet.Fields(n - 1) = cFields.Item(n)
    fora:
    Next
    DSet.Update
    End Sub

    Thanks...
    Alexandre Munhoz
    alexandre@avipar.com

  2. #2
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    224
    Provided Answers: 1

    Exclamation Re: Date Field Problem

    [QUOTE][SIZE=1]Originally posted by lexmoz
    I had a problem when ive tryed to update a date field.
    The error message is
    "[Mysql][Odbc 3.51 Driver][mysqld-3.23.51] You hav an error in your syntax near '00-2001' AND 'avteffective'='01/11/1983' AND 'avtrecurring'='3' AND.... At line 1"
    I version mysql 4, the message is "unable to locate the row for update..."
    Ive tryed to use Date and DateTime data type, and it dont work...
    This happen only in when the register is edited...


    Well, for one thing MySQL usually expects date, timestamp and DateTime values to be in the format:

    YYYY-MM-DD with dashes separators.

    And if you want to avoid all kinds of problems, make sure you have a primary key for every table you'll be updating. Otherwise, there's no way you can fetch the proper row if it can't be uniquely identified.

    Hope this helps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •