RecordCount with MySQL

Results 1 to 2 of 2

Thread: RecordCount with MySQL

  1. #1
    Join Date
    Dec 1969

    Default RecordCount with MySQL

    I have just upgraded from Access to MySQL and am having a problem using RecordCount to get the number of records. It was working with Access but now it returns -1. I have the CursorType set to Static, which should support the RecordCount, but it doesn work. MySQL's web page mentions that to use RecordCount with ASP you need to use the option flag "Return matching rows". I dont know what they mean by this flag or how to use it. Any ideas?

  2. #2
    Join Date
    Dec 1969

    Default You misread or missed...

    ...the proper spot in the MyODBC docs:<BR><BR><BR><BR>And on that page you find:<BR><BR>**** QUOTE ****<BR>When you are coding with the ADO API and MyODBC you need to put attention in some default properties that aren&#039;t supported by the MySQL server. For example, using the CursorLocation Property as adUseServer will return for the RecordCount Property a result of -1. To have the right value, you need to set this property to adUseClient, like is showing in the VB code below: <BR>Dim myconn As New ADODB.Connection<BR>Dim myrs As New Recordset<BR>Dim mySQL As String<BR>Dim myrows As Long<BR><BR>myconn.Open "DSN=MyODBCsample"<BR>mySQL = "SELECT * from user"<BR>myrs.Source = mySQL<BR>Set myrs.ActiveConnection = myconn<BR>myrs.CursorLocation = adUseClient &#039; &#060;&#060;&#060; $$$ THIS IS THE MAGIC!!!<BR>myrs.Open<BR>myrows = myrs.RecordCount<BR><BR>myrs.Close<BR>myconn.Close <BR>********* end quote ********<BR><BR>Needing to utilize adUseClient in order to get the RecordCount to work is moderately common with various DBs, not unique to MySQL.<BR><BR><BR>

Posting Permissions

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