+ Reply to Thread
Results 1 to 4 of 4

CopyFromRecordset incorrect mysql/myODBC 5.1 (excel 2007)

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2011
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    4

    CopyFromRecordset incorrect mysql/myODBC 5.1 (excel 2007)

    hello,

    I have myODBC 5.1 installed and I am trying to acces a database
    establishing a connection and executing queries does work
    but if I use the following
    RS.Open query
    rsRows = rsSheet.Range("A1").CopyFromRecordset(RS)
    I will not get correct results in rsSheet

    my query (simplified):
    select distinct
    a.val1,
    a.val2,
    b.val3,
    c.val4
    from tabA a, tabB b
    only a.val1 and a.val2 are copied, everything else is missing.
    but if I remove b.val3 from my query then a.val1, a.val2 and a.val4 are copied

    the weird thing is that using "MySQL ODBC 3.51 Driver" is working fine. just "MySQL ODBC 5.1 Driver" has problems

    the resultset is correct. how do I know? using:
    rcArray = RS.GetRows
    and then iterating through all elements using 2 for loops, will give me correct values

    of course you can say to use the for loops, but this does not look nice espacially as there is a function for this purpose, which might also have better performance

    plz do not tell me to use version 3.51 because this code is going to be run on other machines where downgrading is no option

  2. #2
    Registered User
    Join Date
    07-25-2011
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: CopyFromRecordset incorrect mysql/myODBC 5.1 (excel 2007)

    noone can help?

  3. #3
    Forum Contributor
    Join Date
    12-26-2010
    Location
    Kansas City, Kansas
    MS-Off Ver
    Excel 2007
    Posts
    147

    Re: CopyFromRecordset incorrect mysql/myODBC 5.1 (excel 2007)

    ZT

    I _CANNOT_ help but want to point out some things.
    .
    But first
    .
    a) This SQL

    select distinct
    a.val1,
    a.val2,
    b.val3,
    c.val4
    from tabA a, tabB b
    cannot work because there is no table C (c.val4)

    Assuming a typo the SQL is

    select distinct
    a.val1,
    a.val2,
    b.val3,
    a.val4
    from tabA a, tabB b
    .
    Correct?
    .
    (a) If the purpose of the SQL is to bring back fields
    from two different tables and the tables are NOT JOINED
    on some common field e.g a.ID = b.ID or a.CustNum = b.CustNum

    That means for every record in Table A you will get all the records
    in Table B. IOW - lots of records.

    (b) In Access or Oracle there are FIELD TYPES like MEMO and (I forget
    the Field Type in Oracle - BLOB?)

    These are HUGE field types - and depending on the PROVIDER that you are
    using - a RECORDSET may not be able to hold the FIELD data.
    .
    And that is why you are getting the strange result you see.
    .
    I am pretty certain MYSQL would have the same field type but I don't
    know the name of the field type. (Guess - BLOB)
    .
    I would examine the field types in Table A and Table B and see if one of
    them is a BLOB or whatever MYSQL calls them.
    .
    If so - other than a Provider that can support that type
    of Field Type - I cannot think of a CopyFromRecordSet solution.
    .
    HTH
    regards
    John

  4. #4
    Registered User
    Join Date
    07-25-2011
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: CopyFromRecordset incorrect mysql/myODBC 5.1 (excel 2007)

    yes it was a typo

    A) it does not matter if i join them or filter results using where.
    the point is: using 3.51 i get correct results and usint 5.1 i do not (using the same query)

    B) as above what does this have to do with bad results in this case: look at A)

    in another forum someone pointed me to this bug: http://bugs.mysql.com/bug.php?id=29633

    adding this line:
    RS.CursorLocation = adUseClient
    before using RS.open seems to have fixed it

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1