![]() |
RecordCount not working
I am trying to read data from a mysql database from within an excel
makro. My problem is, that no matter if I get data (i know there are several records returned, because I can output fields' values) or not - recordcount is always -1 Example: -- Dim link As New ADODB.Connection link.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=localhost;" _ & "DATABASE=test;" _ & "UID=root;" _ & "PWD=secret;" link.Open Set rs = New ADODB.Recordset query = "select * from mytable" rs.Open query, link MsgBox rs.RecordCount ' -1 rs.movefirst msgbox rs.fields"name" ' jim rs.close link.close -- I can't see where I deviated from the mysql odbc reference.... they also use recordcount.... http://dev.mysql.com/doc/refman/5.0/...ogramming.html Thx in advance.. |
RecordCount not working
Give this a try. Before calling link.Open, set the cursorlocation. So:
link.CursorLocation = adUseClient link.Open "T. S." wrote: I am trying to read data from a mysql database from within an excel makro. My problem is, that no matter if I get data (i know there are several records returned, because I can output fields' values) or not - recordcount is always -1 Example: -- Dim link As New ADODB.Connection link.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=localhost;" _ & "DATABASE=test;" _ & "UID=root;" _ & "PWD=secret;" link.Open Set rs = New ADODB.Recordset query = "select * from mytable" rs.Open query, link MsgBox rs.RecordCount ' -1 rs.movefirst msgbox rs.fields"name" ' jim rs.close link.close -- I can't see where I deviated from the mysql odbc reference.... they also use recordcount.... http://dev.mysql.com/doc/refman/5.0/...ogramming.html Thx in advance.. |
All times are GMT +1. The time now is 09:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com