Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-354

SELECT Query using VBA returning wrong results

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • Windows 10 - Microsoft 365

    Description

      Hi all,

      I report a bug using ODBC connector through VBA. Assuming I have a table named 'companies' with 3 rows in there.
      When doing this query:

      sqlQuery = "SELECT DISTINCT idCompany" _
              & " FROM companies" _
      rsDB.Open sqlQuery, conDB, adOpenDynamic
      

      Then it returns the correct results:

      idCompany
      1
      2
      3

      But when doing a query with more than one field, then

      sqlQuery = "SELECT DISTINCT idCompany, name" _
              & " FROM companies" _
      rsDB.Open sqlQuery, conDB, adOpenDynamic
      

      The query returns this:

      idCompany name
      1 company 1
      1 company 1
      2 company 2

      This means that any query with more than one field selected returns the first row twice, and doesn't show the last row. Even with more than 20+ rows in my table the result is the same...

      Any idea of the origin of this bug?

      Thanks a lot

      – EDIT –
      Here is the connection string used in VBA:

      Set conDB = New ADODB.Connection
      Set rsDB = New ADODB.recordSet
      Set rsDBCol = New ADODB.recordSet
      conDB.connectionString = "DRIVER={MariaDB ODBC 3.1 Driver};" _
          & "SERVER=server-1;" _
          & "DATABASE=db_pricing;" _
          & "PORT=3306" _
          & "UID=xuser;" _
          & "PWD=xxxxxxxxxxx;" _
          & "OPTION=3"
       
      conDB.Open
      'rsDB.CursorLocation = adUseServer
      'rsDBCol.CursorLocation = adUseServer
      

      I've figured out that the use of 'rsDB.CursorLocation=aduseServer' is the cause of the issue. When commenting these 2 lines, my requests seems to work well.

      Attachments

        Activity

          People

            Lawrin Lawrin Novitsky
            jore Jehan Oré
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.