Reordcount = -1

  • Thread starter Thread starter George Hester
  • Start date Start date
G

George Hester

In this example:

http://support.microsoft.com/default.aspx?scid=kb;en-us;248255

I just put one command button on a form and this is the code for the Click event:

Private Sub Command1_Click()

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

Dim rec As ADODB.Record
Set rec = New ADODB.Record

Dim stm As ADODB.Stream
Set stm = New ADODB.Stream


'Specify adCmdTableDirect when opening a document or folder
rs.Open "test.txt", "Provider=MSDAIPP.DSO;" & _
"Data Source=http://localhost/test", _
adOpenForwardOnly, adLockReadOnly, adCmdTableDirect

Debug.Print rs.RecordCount
End Sub

There are no reords. At least that is what the result -1 is telling me I think. What's wrong?
Thanks.
 
In this example:

http://support.microsoft.com/default.aspx?scid=kb;en-us;248255

I just put one command button on a form and this is the code for the Click
event:

Private Sub Command1_Click()

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

Dim rec As ADODB.Record
Set rec = New ADODB.Record

Dim stm As ADODB.Stream
Set stm = New ADODB.Stream


'Specify adCmdTableDirect when opening a document or folder
rs.Open "test.txt", "Provider=MSDAIPP.DSO;" & _
"Data Source=http://localhost/test", _
adOpenForwardOnly, adLockReadOnly, adCmdTableDirect

Debug.Print rs.RecordCount
End Sub

There are no reords. At least that is what the result -1 is telling me I
think. What's wrong?
Thanks.

..RecordCount doesn't indicate how many records are contained in a dynaset-,
snapshot-, or forward-only-type Recordset object until all records have been
accessed. Once the last record has been accessed, the RecordCount property
indicates the total number of undeleted records in the Recordset or TableDef
object. To force the last record to be accessed, use the .MoveLast method on
the Recordset object.
 
Thanks for the input. I did this:

rs.Open "test.txt", "Provider=MSDAIPP.DSO;" & _
"Data Source=http://localhost/test", _
adOpenForwardOnly, adLockReadOnly, adCmdTableDirect
rs.MoveLast
Debug.Print rs.RecordCount

the result was:

Run-time error '-2147217884 (80040e24) at rs.MoveLast

Looks like there are no records in the recordset. Did I miss something? Thanks.
 
Thanks for the input. I did this:

rs.Open "test.txt", "Provider=MSDAIPP.DSO;" & _
"Data Source=http://localhost/test", _
adOpenForwardOnly, adLockReadOnly, adCmdTableDirect
rs.MoveLast
Debug.Print rs.RecordCount

the result was:

Run-time error '-2147217884 (80040e24) at rs.MoveLast

Looks like there are no records in the recordset. Did I miss something?
Thanks.


See if this sheds some light on the subject:

http://support.microsoft.com/default.aspx?scid=kb;en-us;245359

Looking at the Recordset Object section, I noticed a couple of the .Open
parameters are left blank. That might be part of the problem. (Defaults are
sometimes good things.)

Does "test.txt" exist in the "test" subdirectory of "localhost's" web? Since
you're going after "localhost", it's right there on your machine.
 
OK whittled it down to this. None of the examples that Microsoft presents that include adCmdTableDirect will work. Actually it doesn't matter. It turns out for this to be used I have to allow file browsing. Since that's not going to happen on to the next idea. The reason for this is I wanted to read a OLE Object put it in a disconnected Recordset and then pop it into a database that is ready for it. Believe it or not this could have worked. At least I think so.

--
George Hester
__________________________________
Yes the state of the connect = 1.

rs.State = 1

I'll check out that link thanks.
 
Back
Top