VB- ADO Returns a recordcount of -1
Posted on 2003-02-24
This should be a really easy one. I have the following code:
SQLConnect = "Provider=SQLOLEDB;Data Source=CLUSTERNAME\CLUSTERINSTANCE;Initial Catalog=MyTable;Integrated Security=SSPI;"
Conn1.ConnectionString = SQLConnect
Cmd1.ActiveConnection = Conn1
Cmd1.CommandText = "Select MyColumn from MyTable where Need2Publish = 1"
Set Rs1 = Cmd1.Execute
i = 1
x = 1
intCount = Rs1.RecordCount
This always produces a RecordCount of -1, even though there are 2 records? I know for a fact there are two records because if I do this:
intCount = 2
If intCount > 0 Then
Do Until Rs1.EOF
strVarName(i) = Rs1.Fields(0).Value
i = i + 1
It returns my 2 values in the message box...
Does anyone have an explanation to this?