.pls help me..
using adodc
how to count the records entered in the table.
i've tried this code
but it always returns -1Code:Dim rec As ADODB.Recordset
Text1.Text = rec.RecordCount
??? why..:confused:
Printable View
.pls help me..
using adodc
how to count the records entered in the table.
i've tried this code
but it always returns -1Code:Dim rec As ADODB.Recordset
Text1.Text = rec.RecordCount
??? why..:confused:
There are couple of reasons:
1. You need to set recordset CursorLocation to client first.
2. Not every data provider supports the record count.Code:Dim RST As ADODB.Recordset
Set RST = New ADODB.Recordset
rst.CursorLocation = adUseClient
ty i will try.
:)
thanks....
i got it...
pls help me, if i will encounter another problem in my way..
thank you very much!
before the prob.
i would like to thanks for your kindness.
thanks for the answers.
pls help me for this another prob.
here is the link
http://www.vbforums.com/showthread.php?t=650166:thumb:
i got a trouble.
pls help me again.
here is the code i've entered.
then the attachment is the screen shot of the error.Code:Private Sub Command1_Click()
Set rec = New ADODB.Recordset
rec.CursorLocation = adUseClient
'to see how many records in the table
Text1.Text = rec.CursorLocation
MSFlexGrid1.TextMatrix(1, 0) = rec.Fields(0)
End Sub
the error is in the rec.fields (0) and said that:
Item cannot be found in the collection corresponding to the requested name or ordinal.
That is because there is no column name CursorLocation in the record set. That is an attribute of a recordset. What you want is rec.RecordCount
my first problem is how to count the records.. but it is resolved using the codes given by RhinoBull...
then now, i have the problem of viewing the record using the msflexgrid
...
if i'm not mistaken, the code.
is use to move the cursor to the last row of the table.Code:Set rec = New ADODB.Recordset
rec.CursorLocation = adUseClient
using other command button. (command2)
i can view it, and there is no error.
but i want is to know how many records and the same time viewing the record in the msflexgrid.
When you use a client side cursor, the recordcount property will return an accurate number.
-1 is returned for a recordcount only when you are using a server side cursor.
thanks sir, i got it. (about the client and server side cursor)
but my problem now,,,
the second problem i've mentioned above. (with attachment)
You are not selecting any records - if you do then at least it's not presented here.
There must some kind of "Select * From..." sql staement executed.
If you are beginner to database programming I would recommend checking out Database FAQ section for lots tutorials, tips and sample code.