Results 1 to 4 of 4

Thread: NEW Mysql Server prob to insert query date

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    NEW Mysql Server prob to insert query date

    Code:
    SQL = "INSERT INTO UTENZE ([APRI], [USER] , [A_ORA], [NOMINATIVO]) VALUES (CURDATE(),'" & _
            VETTORE & "',CURTIME(),'" & UTENTE_CORRENTE & "')"    
        CONN.Execute SQL, , adCmdText + adExecuteNoRecords
    have error in image.

    note:
    the last var UTENTE_CORRENTE in this case is blank

    APRI and A_ORA are datetime
    USER and NOMINATIVO are Varchar

    my conn:

    Option Explicit
    Public Function connectMysql(USERNAME As String, PASSWD As String, SERVERIP As String, DB As String, CONN As ADODB.Connection, RS As ADODB.Recordset)

    Set CONN = New ADODB.Connection
    With CONN
    .CommandTimeout = 999999
    .ConnectionTimeout = 999999
    .Mode = adModeReadWrite
    .CursorLocation = adUseClient
    .ConnectionString = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & SERVERIP & ";UID=" & USERNAME & ";PWD=" & PASSWD & ";DATABASE=" & DB & ";" & _
    "OPTION=3"
    .Open
    End With

    End Function
    Sub INIZIO1()

    If CONN Is Nothing Then
    Call connectMysql("root", "sal21", "127.0.0.1", "BT", CONN, RS)
    End If

    End Sub
    Attached Images Attached Images  

  2. #2
    Addicted Member
    Join Date
    Oct 2008
    Location
    Califorina
    Posts
    235

    Re: NEW Mysql Server prob to insert query date

    Does you column names have brackets ([]) in them? MySQL doesn't use the [] like MSSQL does for mysql you would do `APRI`

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Re: NEW Mysql Server prob to insert query date

    Quote Originally Posted by smendoza View Post
    Does you column names have brackets ([]) in them? MySQL doesn't use the [] like MSSQL does for mysql you would do `APRI`
    OK!!!


    FIRST STEEP RESOLVED, TKS.!!!!!!!!

    but to insert date is correct the format yyy-mm-dd and hh:mm:ss

    if yes how to insert this two element in a vb6 string query?

    with #" ...."# similar access string query or...?

  4. #4
    Addicted Member
    Join Date
    Oct 2008
    Location
    Califorina
    Posts
    235

    Re: NEW Mysql Server prob to insert query date

    What data type is your APRI column? CURDATE() should insert the date into the date column in the correct format. I know Toad for mySQL reformats the data to mm/dd/yyyyy HH:MM:SS.

    If you want to type in a date just wrap it in qoutes like this -> '2013-03-22'

    Here is all the Date functions for mysql
    https://dev.mysql.com/doc/refman/5.5...functions.html

Posting Permissions

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



Click Here to Expand Forum to Full Width