[ODBC-396] Classic asp recordcount not working Created: 2023-09-07  Updated: 2023-09-17  Resolved: 2023-09-15

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.1.18, 3.1.19
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Simone Abello Assignee: Lawrin Novitsky
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

windows 10, IIS 10, mariadb 10.11.2


Issue Links:
Blocks
blocks ODBC-192 ODBC 3.0.6 VBA Error on Query Closed

 Description   

Retrieve recordcount property from an ADO recorset give everytime -1, i tried all combination of cursortype and locktype, nothing changed. Tried also use movelast and movefirst as suggested on forums in the web but the problem persists.
Run this code to reproduce the issue
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER=

{MariaDB ODBC 3.1 Driver}

;port=3306;SERVER=127.0.0.1;UID=XXX;PWD=XXX;database=test;charset=UTF8;")
SQL = "SELECT codArch FROM archivi;"

set RS = Server.CreateObject("ADODB.RecordSet")
RS.open SQL,conn, 1, 3
'RS.movelast
'RS.movefirst
response.Write "record: "& RS.recordCount

RS.close
set RS = Nothing
Conn.close
set Conn = Nothing
%>

the table structure is
CREATE TABLE IF NOT EXISTS `archivi` (
`codarch` int(11) NOT NULL DEFAULT 0,
`codcli` int(11) DEFAULT NULL,
`descrizione` char(50) DEFAULT NULL,
`perc` char(255) DEFAULT NULL,
`mariadb` char(50) DEFAULT NULL,
`codtipoarch` int(11) DEFAULT NULL,
`Bloccato` int(11) DEFAULT NULL,
`controlloRichieste` int(11) DEFAULT NULL,
`dataCaricamentoDoc` char(50) DEFAULT NULL,
`ordine` int(11) DEFAULT NULL,
`visibile` int(11) DEFAULT NULL,
`codStatoArch` int(11) DEFAULT NULL,
`dataRitiro` datetime DEFAULT NULL,
`dataMacero` datetime DEFAULT NULL,
PRIMARY KEY (`codarch`),
KEY `codarch` (`codarch`),
KEY `codtipoarch` (`codtipoarch`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;



 Comments   
Comment by Lawrin Novitsky [ 2023-09-15 ]

Thank you for your report.
If you set cursor location to adUseClient in connection or rs prior to opening it, i.e. something like rs.CursorLocation = adUseClient, RecordCount will show up.
Quick googling didn't give me distinct confirmation, but some say that it should be this way, and recordCount should only work with adUseClient.
Besides I checked with mysql's driver - it gave the same result.
Also I looked thru ODBC trace for the case of adUseServer, and it seems like ADO requested, and driver provided number of rows. Even in 2 different ways, but ADO still decides to return -1. Kinda also supports the idea, that adUseClient is the way to go here, if you want to get recordCount.

I am gonna close the report as not a bug. If you have objections - please re-open the ticket, and give some justification why it should be working with adUseServer as well

Comment by Lawrin Novitsky [ 2023-09-17 ]

Well, looks like it should not work for some cursor types, but not for cursor location, according to documentation. Besides we don't do really server cursors with MariaDB/MySQL servers. So, it's more like "won't fix". Unless we are provided a good reason for that.

Generated at Thu Feb 08 03:28:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.