getting rowcount

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()
 
S

segue

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.
 
S

segue

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top