RecordCount not working

T

T. S.

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/en/myodbc-examples-programming.html

Thx in advance..
 
G

Guest

Give this a try. Before calling link.Open, set the cursorlocation. So:

link.CursorLocation = adUseClient
link.Open
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top