--=_NextPart_000_0057_01C44D4D.A2D86E10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello,
I am using the function below to get some values form database.
However for RecordCount it always returns -1.
Any clues hot to fix it?
Thx
YuriW
Function RunSQL (sConnection_String, sSQL_QUERY) Dim db_object Dim sSQL_string
'connection_string =3D "DSN=3DMagnetic;UID=3Dlaurel;PWD=3Duklever"
sSQL_string =3D sSQL_QUERY
' Create the conection object.
Set db_object =3D CreateObject("ADODB.Connection")
' or use this method if a DSN entry was created.
db_object.Open(sConnection_String)
' Get the recordset returned from a select query.
Set recordset =3D db_object.Execute(sSQL_string)
' Display the results of the query.
sOut =3D recordset.RecordCount
RunSQL =3D sOut
' Close the database connection.
db_object.Close
Set db_object =3D Nothing
End Function
--=_NextPart_000_0057_01C44D4D.A2D86E10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Hello,
I am using the function below to get some values form = database.
However for RecordCount it always returns -1.
Any clues hot to fix it?
Thx
YuriW
Function RunSQL (sConnection_String, sSQL_QUERY) Dim = db_object Dim sSQL_string 'connection_string =3D "DSN=3DMagnetic;UID=3Dlaurel;PWD=3Duklever" sSQL_string =3D sSQL_QUERY
' Create the conection object. Set db_object =3D CreateObject("ADODB.Connection")
' or use this method if a DSN entry was = created. db_object.Open(sConnection_String)
' Get the recordset returned from a select query. = Set recordset =3D db_object.Execute(sSQL_string)
' Display the results of the query.
sOut =3D recordset.RecordCount
RunSQL =3D sOut
' Close the database connection. = db_object.Close Set db_object =3D Nothing
End Function
</FONT></FONT>
--=_NextPart_000_0057_01C44D4D.A2D86E10--http://www.aspfaq.com/2193
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> wrote in message
news:7Mnxc.68469$yx3.34214@.newssvr29.news.prodigy.com...
Hello,
I am using the function below to get some values form database.
However for RecordCount it always returns -1.
Any clues hot to fix it?
Thx
YuriW
Function RunSQL (sConnection_String, sSQL_QUERY)
Dim db_object
Dim sSQL_string
'connection_string = "DSN=Magnetic;UID=laurel;PWD=uklever"
sSQL_string = sSQL_QUERY
' Create the conection object.
Set db_object = CreateObject("ADODB.Connection")
' or use this method if a DSN entry was created.
db_object.Open(sConnection_String)
' Get the recordset returned from a select query.
Set recordset = db_object.Execute(sSQL_string)
' Display the results of the query.
sOut = recordset.RecordCount
RunSQL = sOut
' Close the database connection.
db_object.Close
Set db_object = Nothing
End Function|||Thanks you. I am still not clear how to change the code in order to fix it?
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eyU6tjYTEHA.3580@.TK2MSFTNGP09.phx.gbl...
> http://www.aspfaq.com/2193
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> wrote in message
> news:7Mnxc.68469$yx3.34214@.newssvr29.news.prodigy.com...
> Hello,
> I am using the function below to get some values form database.
> However for RecordCount it always returns -1.
> Any clues hot to fix it?
> Thx
> YuriW
> Function RunSQL (sConnection_String, sSQL_QUERY)
> Dim db_object
> Dim sSQL_string
> 'connection_string = "DSN=Magnetic;UID=laurel;PWD=uklever"
> sSQL_string = sSQL_QUERY
> ' Create the conection object.
> Set db_object = CreateObject("ADODB.Connection")
> ' or use this method if a DSN entry was created.
> db_object.Open(sConnection_String)
> ' Get the recordset returned from a select query.
> Set recordset = db_object.Execute(sSQL_string)
> ' Display the results of the query.
> sOut = recordset.RecordCount
> RunSQL = sOut
> ' Close the database connection.
> db_object.Close
> Set db_object = Nothing
> End Function
>|||Maybe you need to look at the article again?
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> wrote in message
news:dnoxc.68491$iR3.59055@.newssvr29.news.prodigy.com...
> Thanks you. I am still not clear how to change the code in order to fix
it?
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:eyU6tjYTEHA.3580@.TK2MSFTNGP09.phx.gbl...
> > http://www.aspfaq.com/2193
> >
> > --
> > http://www.aspfaq.com/
> > (Reverse address to reply.)
> >
> >
> >
> >
> > "Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> wrote in message
> > news:7Mnxc.68469$yx3.34214@.newssvr29.news.prodigy.com...
> > Hello,
> > I am using the function below to get some values form database.
> > However for RecordCount it always returns -1.
> > Any clues hot to fix it?
> >
> > Thx
> > YuriW
> >
> > Function RunSQL (sConnection_String, sSQL_QUERY)
> > Dim db_object
> > Dim sSQL_string
> >
> > 'connection_string = "DSN=Magnetic;UID=laurel;PWD=uklever"
> > sSQL_string = sSQL_QUERY
> >
> > ' Create the conection object.
> > Set db_object = CreateObject("ADODB.Connection")
> >
> > ' or use this method if a DSN entry was created.
> > db_object.Open(sConnection_String)
> >
> > ' Get the recordset returned from a select query.
> > Set recordset = db_object.Execute(sSQL_string)
> >
> > ' Display the results of the query.
> >
> > sOut = recordset.RecordCount
> >
> > RunSQL = sOut
> >
> > ' Close the database connection.
> > db_object.Close
> > Set db_object = Nothing
> >
> > End Function
> >
> >
>|||This is a multi-part message in MIME format.
--=_NextPart_000_00C3_01C44D70.C4F36D60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Recordcount is not supported with the default forward-only cursor. You =can try to set the type of cursor before you excute your SQL code.
"Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> wrote in message =news:7Mnxc.68469$yx3.34214@.newssvr29.news.prodigy.com...
Hello,
I am using the function below to get some values form database.
However for RecordCount it always returns -1.
Any clues hot to fix it?
Thx
YuriW
Function RunSQL (sConnection_String, sSQL_QUERY) Dim db_object Dim sSQL_string
'connection_string =3D "DSN=3DMagnetic;UID=3Dlaurel;PWD=3Duklever"
sSQL_string =3D sSQL_QUERY
' Create the conection object.
Set db_object =3D CreateObject("ADODB.Connection")
' or use this method if a DSN entry was created.
db_object.Open(sConnection_String)
' Get the recordset returned from a select query.
Set recordset =3D db_object.Execute(sSQL_string)
' Display the results of the query.
sOut =3D recordset.RecordCount
RunSQL =3D sOut
' Close the database connection.
db_object.Close
Set db_object =3D Nothing
End Function
--=_NextPart_000_00C3_01C44D70.C4F36D60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Recordcount is not supported with the default forward-only cursor. =You can try to set the type of cursor before you excute your SQL code.
"Yuri Weinstein (HotMail)"
Hello,
I am using the function below to get some values form =database.
However for RecordCount it always returns -1.
Any clues hot to fix it?
Thx
YuriW
Function RunSQL (sConnection_String, sSQL_QUERY) Dim =db_object Dim sSQL_string 'connection_string =3D "DSN=3DMagnetic;UID=3Dlaurel;PWD=3Duklever" sSQL_string =3D sSQL_QUERY
' Create the conection object. Set db_object =3D = CreateObject("ADODB.Connection")
' or use this method if a DSN entry was =created. db_object.Open(sConnection_String)
' Get the recordset returned from a select =query. Set recordset =3D db_object.Execute(sSQL_string)
' Display the results of the query.
sOut =3D recordset.RecordCount
RunSQL =3D sOut
' Close the database connection. db_object.Close Set db_object =3D Nothing
End Function
--=_NextPart_000_00C3_01C44D70.C4F36D60--|||Got it, thx!
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eyU6tjYTEHA.3580@.TK2MSFTNGP09.phx.gbl...
> http://www.aspfaq.com/2193
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> wrote in message
> news:7Mnxc.68469$yx3.34214@.newssvr29.news.prodigy.com...
> Hello,
> I am using the function below to get some values form database.
> However for RecordCount it always returns -1.
> Any clues hot to fix it?
> Thx
> YuriW
> Function RunSQL (sConnection_String, sSQL_QUERY)
> Dim db_object
> Dim sSQL_string
> 'connection_string = "DSN=Magnetic;UID=laurel;PWD=uklever"
> sSQL_string = sSQL_QUERY
> ' Create the conection object.
> Set db_object = CreateObject("ADODB.Connection")
> ' or use this method if a DSN entry was created.
> db_object.Open(sConnection_String)
> ' Get the recordset returned from a select query.
> Set recordset = db_object.Execute(sSQL_string)
> ' Display the results of the query.
> sOut = recordset.RecordCount
> RunSQL = sOut
> ' Close the database connection.
> db_object.Close
> Set db_object = Nothing
> End Function
>|||In "Display the results of the query" you should iterate through recordset
with MoveFirst/MoveNext. Add counter into this cycle
dim counter
counter = 0
rs.MoveFirst
while not rs.EOF
... display record
counter = counter + 1
rs.MoveNext
wend
'here counter contains number of records
//--
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE
"Yuri Weinstein (HotMail)" <yuriw_NOSPAM@.hotmail.com> '?/'' ?
'' '?: news:7Mnxc.68469$yx3.34214@.newssvr29.news.prodigy.com...
Hello,
I am using the function below to get some values form database.
However for RecordCount it always returns -1.
Any clues hot to fix it?
Thx
YuriW
Function RunSQL (sConnection_String, sSQL_QUERY)
Dim db_object
Dim sSQL_string
'connection_string = "DSN=Magnetic;UID=laurel;PWD=uklever"
sSQL_string = sSQL_QUERY
' Create the conection object.
Set db_object = CreateObject("ADODB.Connection")
' or use this method if a DSN entry was created.
db_object.Open(sConnection_String)
' Get the recordset returned from a select query.
Set recordset = db_object.Execute(sSQL_string)
' Display the results of the query.
sOut = recordset.RecordCount
RunSQL = sOut
' Close the database connection.
db_object.Close
Set db_object = Nothing
End Function
No comments:
Post a Comment