getting rowcount

  • Thread starter Thread starter segue
  • Start date Start date
S

segue

The below code doesn't give me the last record count.
Feedback very appreciated. Thanks for all that you do.

qstring = "SELECT COUNT(*) FROM CustomerInformation "

Dim newSql As New SqlConnection(connectionstr)
newSql.Open()
Dim catCMD As SqlCommand = newSql.CreateCommand()
catCMD.CommandText = qstring
Dim intRecordsAffected = catCMD.ExecuteNonQuery()
newSql.Close()
 
Thanks for the quick response.

I made the ExecuteScalar change and still didn't get the highest number.
My query stopped at 114,278, row 114,279 is empty yet 114,300 isn't.
 
Thanks again for the response. I tried below and get the intRecords = 100,000.

qstring = "SELECT MAX(CustomerID) FROM CustomerInformation "
' ORDER BY RowNumber"

Dim newSql As New SqlConnection(connectionstr)
newSql.Open()
Dim catCMD As SqlCommand = newSql.CreateCommand()
catCMD.CommandText = qstring
Dim intRecordsAffected As Int32 =
CType(catCMD.ExecuteScalar(), Int32)
intRecordsAffected = intRecordsAffected + 1
newSql.Close()
 
Back
Top