Question : Recordset/Database Problem in .vbs

Hi,

In my database(MS SQL) when i query "SELECT * FROM [tableName]", i receive 6 results. But when I tried to run in .vbs, it only gave me 3 results. I have no idea what went wrong.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
    Set rs = CreateObject("ADODB.Recordset")
    Set conn = CreateObject("ADODB.Connection")
    With conn
          .Provider = "SQLOLEDB"
          .Mode = adModeReadWrite
          .ConnectionString = "Data Source = (local); Initial Catalog = xxx; User Id = xxx; Password=xxx"
          .Open
    End With

    strSQLQuery = "SELECT COUNT(*) AS MyRecordCount FROM [tableName]"
    rs.Open strSQLQuery, conn
    
    If Not rs.EOF Then 
    rs.MoveFirst
    Do While Not rs.EOF
        WScript.Echo(rs("MyRecordCount"))
        rs.movenext
    loop
    End If
    
    rs.Close
    Set rs = Nothing
    conn.Close
    Set conn = Nothing

Answer : Recordset/Database Problem in .vbs

Try to change
rs.Open strSQLQuery, conn
to this
rs.Open strSQLQuery, conn, 3, 3

and check the record count of the recordset with this:
wscript.echo rs.RecordCount
Random Solutions  
 
programming4us programming4us