Note that there are some explanatory texts on larger screens.

plurals
  1. POVB6 ADODB.Recordset RecordCount property always returns -1
    primarykey
    data
    text
    <p>I am trying to get some old VB6 code to work with SQL Server Compact. </p> <p>I can connect, open the database and all seems well. I can run insert select commands which work. </p> <p>However the ADODB.Recordset RecordCount property always returns -1 even though I can access the Fields and see the data. Changing the CursorLocation = adUseClient causes a problem when executung the SQL (multiple-step operation generated errors).</p> <pre class="lang-vb prettyprint-override"><code>Option Explicit Private Const mSqlProvider As String = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;" Private Const mSqlHost As String = "Data Source=C:\Database.sdf;" Private mCmd As ADODB.Command ' For executing SQL Private mDbConnection As ADODB.Connection Private Sub Command1_Click() Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset Dim DbConnectionString As String DbConnectionString = mSqlProvider &amp; _ mSqlHost Set mDbConnection = New ADODB.Connection mDbConnection.CursorLocation = adUseServer Call mDbConnection.Open(DbConnectionString) If mDbConnection.State = adStateOpen Then Debug.Print (" Database is open") ' Initialise the command object Set mCmd = New ADODB.Command mCmd.ActiveConnection = mDbConnection mCmd.CommandText = "select * from myTestTable" mCmd.CommandType = adCmdText Set rs = mCmd.Execute Debug.Print rs.RecordCount ' Always returns -1 !! Debug.Print rs.Fields(0) ' returns correct data for first row, first col Debug.Print rs.Fields(1) ' returns correct data for first row, 2nd col Debug.Print rs.Fields(2) ' returns correct data for first row, 3rd col End If End Sub </code></pre> <p>Any advice would be gratefully accepted.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload