Re: RecordCount error
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 17 May 2006 14:32:45 -0500
Hi,
Set cursorType to adOpenStatic and see if that helps. RecordCount returns -1
if the cursorType does not support it.
rsPatient.cursorType = adOpenStatic
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"pmud" <pmud@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5F58CD3A-E48C-4520-82A7-40D536F97DE2@xxxxxxxxxxxxxxxx
Hi Richard,
Thats what my the problem is that the RecordCount is always showing a
value
of -1 even though there are more records returned. I read somewheer on
that its a known issue in VB that sometimes RecordCount will not retun
the
correct value. It was mentioned to use the code below to get around this
error, so i used the code below:
rsRecCount = 0
rsPatient.MoveLast --- ERROR IS SHOWN TO BE IN THIS LINEEnd IF
rsRecCount = rsPatient.RecordCount
If rsRecCount = 0 Then
MsgBox ("This patient has not been yet added to the database")
Thanks
--
pmud
"Richard Mueller" wrote:
Hi,
Since you are not enumerating the recordset, there is no need to move the
cursor backwards. The code should work if you delete the statement:
rsPatient.MoveLast
If you need to move the cursor back and forth, then you need to set the
cursorType property to allow this.
rsPatient.CursorType = adOpenStatic
When you retrieve the RecordCount property, the cursor is moved to the
end.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"pmud" <pmud@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F2022707-A1BC-43C9-85D1-C10C75C9566F@xxxxxxxxxxxxxxxx
Hi,
I have the following function. I need to use RecordCount of the
RecordSet
that is returned when the query is run, but I get the error : "Rowset
does
not support fetching backward. "
Private Function CheckInDatabase(dteBirthDate As Date, arrPatientName()
As
String)
Dim rsRecCount As Integer ' For counting records in a record set
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=UID;Password=PWD;Initial Catalog=DB;Data Source=IP"
cn.Open
MSHFlexGrid1.Clear
Dim rsPatient As ADODB.Recordset
Set rsPatient = New ADODB.Recordset
rsPatient.Open "Select patient_first,patient_last,patient_dob from
patient WHERE patient_dob ='" & dteBirthDate & "' AND ( (
patient_first
= '" & LTrim$(arrPatientName(0)) & "' AND patient_last = '" &
LTrim$(arrPatientName(1)) & "') or (patient_last = '" &
LTrim$(arrPatientName(0)) & "' and patient_first= '" &
LTrim$(arrPatientName(1)) & "'))", cn
Set MSHFlexGrid1.DataSource = rsPatient
rsRecCount = 0
rsPatient.MoveLast --- ERROR IS SHOWN TO BE IN THIS LINE
rsRecCount = rsPatient.RecordCount
If rsRecCount = 0 Then
MsgBox ("This patient has not been yet added to the patient
table
in
the database")
End If
cn.Close
End Function
--
pmud
.
- Follow-Ups:
- Re: RecordCount error
- From: pmud
- Re: RecordCount error
- References:
- Re: RecordCount error
- From: Richard Mueller
- Re: RecordCount error
- From: pmud
- Re: RecordCount error
- Prev by Date: Re: Select query with parameters
- Next by Date: Re: RecordCount error
- Previous by thread: Re: RecordCount error
- Next by thread: Re: RecordCount error
- Index(es):
Relevant Pages
|
Loading