M
Mr Struggler
The following code cycles through the recordset OK, but the RS.RecordCount
is allways = -1. I Need to be able to run a query from which I can tell if a
record exists, if I cant determine the record count I dont know how to
procede
Any help is appreciated
Sub Northwind()
Dim rs As New ADODB.Recordset
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rec As New ADODB.Record
Dim sqlString As String
sqlString = "SELECT * FROM CUSTOMERS"
con.ConnectionString = "Driver={SQL
Server};Server=MYSERVER;Database=NORTHWIND;Uid=sa;Pwd=password;"
con.Open
cmd.ActiveConnection = con
cmd.CommandText = sqlString
cmd.CommandType = adCmdText
Set rs = cmd.Execute(sqlString)
rs.MoveFirst
Do While Not rs.EOF
Debug.Print rs.Fields(0)
rs.MoveNext
Loop
con.Close
Set con = Nothing
Set cmd = Nothing
End Sub
is allways = -1. I Need to be able to run a query from which I can tell if a
record exists, if I cant determine the record count I dont know how to
procede
Any help is appreciated
Sub Northwind()
Dim rs As New ADODB.Recordset
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rec As New ADODB.Record
Dim sqlString As String
sqlString = "SELECT * FROM CUSTOMERS"
con.ConnectionString = "Driver={SQL
Server};Server=MYSERVER;Database=NORTHWIND;Uid=sa;Pwd=password;"
con.Open
cmd.ActiveConnection = con
cmd.CommandText = sqlString
cmd.CommandType = adCmdText
Set rs = cmd.Execute(sqlString)
rs.MoveFirst
Do While Not rs.EOF
Debug.Print rs.Fields(0)
rs.MoveNext
Loop
con.Close
Set con = Nothing
Set cmd = Nothing
End Sub