dcsimg
Results 1 to 7 of 7

Thread: [RESOLVED] open table in mysql with special character

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,743

    Resolved [RESOLVED] open table in mysql with special character

    Code:
    Option Explicit
    '************************************
    Dim CN As ADODB.Connection
    Dim RS As ADODB.Recordset
    Private Sub Form_Load()
    
        Set CN = New ADODB.Connection
        Set RS = New ADODB.Recordset
        
        Dim TABELLA As Variant
        TABELLA = "statistica"
    
        CN.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=192.168.1.3;" & " DATABASE=test;" & "UID=root;PWD=sal21;"
        CN.Open
    
        'RS.Open "select * from statistica", CN, adOpenDynamic, adLockOptimistic
        RS.Open "select * from [98-2018]", CN, adOpenDynamic, adLockOptimistic
        
        Set RS = CN.Execute("select * from statistica")
    
    End Sub
    rs with statistica work fine, instead wit 08-2018 have error!
    I think mysdql dont know the specila chr "-"?
    Boh?
    Last edited by luca90; Sep 1st, 2018 at 05:22 PM.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,740

    Re: open table in mysql with special character

    I don't use mysql so I don't know if that is an acceptable table name. But you are trying to open RS twice. Haven't use ADODB in a while but that might be a problem. You did tell us what the error said.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,743

    Re: open table in mysql with special character

    Quote Originally Posted by wes4dbt View Post
    I don't use mysql so I don't know if that is an acceptable table name. But you are trying to open RS twice. Haven't use ADODB in a while but that might be a problem. You did tell us what the error said.
    I have quote the first open recordset

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,740

    Re: open table in mysql with special character

    And what happened, what is the error, which line of code is causing the error??

    Also, this line of code makes no sense, you've already loaded another table into RS.
    Code:
    Set RS = CN.Execute("select * from statistica")

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,435

    Re: open table in mysql with special character

    Use backticks around "98-2018" --> `98-2018`
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    I say you're crazy not to!
    --------------------------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Java (JSP) Hell!
    Posts
    5,294

    Re: open table in mysql with special character

    Perhaps you need the schema too?
    square brackets [] should be used around the name.
    If you execute the query directly on mysql does it run or error?
    connection.execute is for an executable query (INSERT UPDATE DELETE) if I recall rightly.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,743

    Re: open table in mysql with special character

    Quote Originally Posted by Zvoni View Post
    Use backticks around "98-2018" --> `98-2018`

    RESOLVED With backticks!


    But in italian keyboard dont exists a correspondence of backticks... i have used ALT+96

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width