Recordcount con MYSQL

14/01/2004 - 10:01 por Karma | Informe spam
He mudado a MYSQL y no me saca el recordcount de un RS, me saca (-1) es
decir encuentra registros.

He probado esto que ví por ahí

Const adOpenStatic = 3
Const adCmdText = &H0001

objrst4.Open "SELECT * FROM USUARIOS",adopenstatic,adcmdtext

sigue sacando -1

y no quiero contarlo a mano ni haciendo whiles, alguna opcion? Gracias
anticipadas

Preguntas similare

Leer las respuestas

#1 Jimy
15/01/2004 - 00:02 | Informe spam
Prueba
objrst4.Open "SELECT * FROM
USUARIOS",adopenstatic,adLockOptimistic,adcmdtext

adcmtext no es necesario ponerlo.
también puedes poner

objrst4.Open "SELECT * FROM USUARIOS",3,3

es la que yo utilizo.

Salu2
"Karma" escribió en el mensaje
news:bu30e5$mqh$
He mudado a MYSQL y no me saca el recordcount de un RS, me saca (-1) es
decir encuentra registros.

He probado esto que ví por ahí

Const adOpenStatic = 3
Const adCmdText = &H0001

objrst4.Open "SELECT * FROM USUARIOS",adopenstatic,adcmdtext

sigue sacando -1

y no quiero contarlo a mano ni haciendo whiles, alguna opcion? Gracias
anticipadas


Respuesta Responder a este mensaje
#2 Karma
15/01/2004 - 13:39 | Informe spam
No funciona, gracias

Otra opcion?

"Jimy" escribió en el mensaje
news:pXjNb.375763$
Prueba
objrst4.Open "SELECT * FROM
USUARIOS",adopenstatic,adLockOptimistic,adcmdtext

adcmtext no es necesario ponerlo.
también puedes poner

objrst4.Open "SELECT * FROM USUARIOS",3,3

es la que yo utilizo.

Salu2
"Karma" escribió en el mensaje
news:bu30e5$mqh$
> He mudado a MYSQL y no me saca el recordcount de un RS, me saca (-1) es
> decir encuentra registros.
>
> He probado esto que ví por ahí
>
> Const adOpenStatic = 3
> Const adCmdText = &H0001
>
> objrst4.Open "SELECT * FROM USUARIOS",adopenstatic,adcmdtext
>
> sigue sacando -1
>
> y no quiero contarlo a mano ni haciendo whiles, alguna opcion? Gracias
> anticipadas
>
>


Respuesta Responder a este mensaje
#3 Miguel González
16/01/2004 - 11:00 | Informe spam
Hola karma.

Has probado hacer un moveLast antes del recordCount?

(Cabría capturar el error por si acaso la consulta no devuelve registros)

Saludos!
Miguel

"Karma" escribió en el mensaje news:bu30e5$mqh$
He mudado a MYSQL y no me saca el recordcount de un RS, me saca (-1) es
decir encuentra registros.

He probado esto que ví por ahí

Const adOpenStatic = 3
Const adCmdText = &H0001

objrst4.Open "SELECT * FROM USUARIOS",adopenstatic,adcmdtext

sigue sacando -1

y no quiero contarlo a mano ni haciendo whiles, alguna opcion? Gracias
anticipadas


Respuesta Responder a este mensaje
#4 Jimy
16/01/2004 - 12:34 | Informe spam
Discúlpame pero no te puse el código correcto. El siguiente está verificado
que sí funciona

strDSN "Driver={MYSQL};Server=xxxxxxxxxxx;Database=xxxxx;Uid=xxxxx;Pwd=xxxxx"
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open strDSN
set RS=Server.CreateObject("ADODB.Recordset")
RS.CursorLocation = 3
RS.Open "SELECT * FROM tblempleados", MyConn, 0 ,1

A continuación pongo unas líneas extraidas de
http://www.mysql.com/products/myodbc/manual.html

ADO
When you are coding with the ADO API and Connector/ODBC you need to put
attention in some default properties that aren'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:
Dim myconn As New ADODB.Connection
Dim myrs As New Recordset
Dim mySQL As String
Dim myrows As Long

myconn.Open "DSN=MyODBCsample"
mySQL = "SELECT * from user"
myrs.Source = mySQL
Set myrs.ActiveConnection = myconn
myrs.CursorLocation = adUseClient
myrs.Open
myrows = myrs.RecordCount

myrs.Close
myconn.Close

Another workaround is to use a SELECT COUNT(*) statement for a similar query
to get the correct row count.
Active server pages (ASP)
You should use the option flag Return matching rows.

Espero que te funcione.
Salu2
Respuesta Responder a este mensaje
#5 Karma
16/01/2004 - 14:05 | Informe spam
Muchas gracias Jimy, funciona correctamente!!!!
Gracias tambien a Miguel Gonzalez, pero no era lo que quería

a vuestra disposicion

Karma

"Jimy" escribió en el mensaje
news:Q1QNb.382902$
Discúlpame pero no te puse el código correcto. El siguiente está


verificado
que sí funciona

strDSN > "Driver={MYSQL};Server=xxxxxxxxxxx;Database=xxxxx;Uid=xxxxx;Pwd=xxxxx"
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open strDSN
set RS=Server.CreateObject("ADODB.Recordset")
RS.CursorLocation = 3
RS.Open "SELECT * FROM tblempleados", MyConn, 0 ,1

A continuación pongo unas líneas extraidas de
http://www.mysql.com/products/myodbc/manual.html

ADO
When you are coding with the ADO API and Connector/ODBC you need to put
attention in some default properties that aren'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:
Dim myconn As New ADODB.Connection
Dim myrs As New Recordset
Dim mySQL As String
Dim myrows As Long

myconn.Open "DSN=MyODBCsample"
mySQL = "SELECT * from user"
myrs.Source = mySQL
Set myrs.ActiveConnection = myconn
myrs.CursorLocation = adUseClient
myrs.Open
myrows = myrs.RecordCount

myrs.Close
myconn.Close

Another workaround is to use a SELECT COUNT(*) statement for a similar


query
to get the correct row count.
Active server pages (ASP)
You should use the option flag Return matching rows.

Espero que te funcione.
Salu2



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida