Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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.. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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.. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculate working days but change working week | Excel Discussion (Misc queries) | |||
Reg: Incorrect RecordCount when opened a Excel sheet in ADO Recordset | Excel Programming | |||
Recordset.Recordcount Returns -1! | Excel Programming | |||
Adding sales from a non working day to the previous working day | Excel Programming | |||
RecordCount problem | Excel Programming |