Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Reg: Incorrect RecordCount when opened a Excel sheet in ADO Recordset dev[_5_] Excel Programming 4 June 23rd 05 09:48 AM
Recordset.Recordcount Returns -1! Sauron[_24_] Excel Programming 1 June 28th 04 09:11 AM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM
RecordCount problem Terence Excel Programming 1 August 11th 03 09:10 AM


All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"