RE: SQL_CALC_FOUND_ROWS using ODBC driver
Why not just SELECT COUNT(*) FROM MyTableName; and the result will be in rs.Fields(0).Value? John Bonnett -Original Message- From: Nuno Oliveira [mailto:[EMAIL PROTECTED] Sent: Thursday, 15 February 2007 11:34 AM To: [EMAIL PROTECTED]; mysql@lists.mysql.com Subject: SQL_CALC_FOUND_ROWS using ODBC driver Hi, I've used PHP with MySQL and I was able to count the rows of a table by using the following code: SELECT SQL_CALC_FOUND_ROWS * FROM MyTableName; SELECT FOUND_ROWS(); However, I would like to do the same thing using Visual Basic 6... When I set the RS.Source to the first SELECT statement and open it, it run OK but I need to close the RS and open it again using the second SELECT statement. After any of this operations I get a Recordset-RecordsCount = 1 How can I work this out? Thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: SQL_CALC_FOUND_ROWS using ODBC driver
Nils Meyer wrote: SELECT SQL_CALC_FOUND_ROWS doesn't make much sense without a where clause by the way. LIMIT, not where. Thanks for the reply... That seems to make sense. I'm talking about the part of one record being returned containing a field with the number of records. About the LIMIT part, it escaped from the code... I was using it but because the code wasn't working I started changing it and the LIMIT got lost... I've just tried to retrieve the value of the .Fields(0) and yes... It contains the number of records of the table... I hadn't figured this out because using the debug features of VB6 it only show Fields 1 to 38 with the values of my first record (I was using LIMIT 1). Jess Balint wrote: Since you are asking for the row count from the database and not the driver, you have to treat it like a normal result. So rs.Fields(1) should contain the row count. Hi Jess... You say that rs.Fields(1) should contain the row count but I have the row count in rs.Fields(0) and the fields of the row in rs.Fields(1) to rs.Fields(38). Is that normal? Thanks both of you!! :) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: SQL_CALC_FOUND_ROWS using ODBC driver
Hi, Nuno Oliveira wrote: When I set the RS.Source to the first SELECT statement and open it, it run OK but I need to close the RS and open it again using the second SELECT statement. After any of this operations I get a Recordset-RecordsCount = 1 That is actually a correct figure, SELECT FOUND_ROWS() returns exactly one record *CONTAINING* the number of found rows. So you have to access the resultset to get the actual number of rows. SELECT SQL_CALC_FOUND_ROWS doesn't make much sense without a where clause by the way. regards Nils -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: SQL_CALC_FOUND_ROWS using ODBC driver
Nils Meyer wrote: SELECT SQL_CALC_FOUND_ROWS doesn't make much sense without a where clause by the way. LIMIT, not where. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: SQL_CALC_FOUND_ROWS using ODBC driver
On Thu, Feb 15, 2007 at 01:04:26AM +, Nuno Oliveira wrote: Hi, I've used PHP with MySQL and I was able to count the rows of a table by using the following code: SELECT SQL_CALC_FOUND_ROWS * FROM MyTableName; SELECT FOUND_ROWS(); However, I would like to do the same thing using Visual Basic 6... When I set the RS.Source to the first SELECT statement and open it, it run OK but I need to close the RS and open it again using the second SELECT statement. After any of this operations I get a Recordset-RecordsCount = 1 How can I work this out? Since you are asking for the row count from the database and not the driver, you have to treat it like a normal result. So rs.Fields(1) should contain the row count. Jess -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
SQL_CALC_FOUND_ROWS using ODBC driver
Hi, I've used PHP with MySQL and I was able to count the rows of a table by using the following code: SELECT SQL_CALC_FOUND_ROWS * FROM MyTableName; SELECT FOUND_ROWS(); However, I would like to do the same thing using Visual Basic 6... When I set the RS.Source to the first SELECT statement and open it, it run OK but I need to close the RS and open it again using the second SELECT statement. After any of this operations I get a Recordset-RecordsCount = 1 How can I work this out? Thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]