Finding the number of records (count) of a recordset

  • Thread starter Thread starter reidarT
  • Start date Start date
R

reidarT

Dim con2 As New SqlClient.SqlConnection("Data Source=RE....
Dim Tall as Integer
Dim cmdCount As New SqlClient.SqlCommand( _
"SELECT Count(tblToDo.ToDoID) AS AntallMeldinger " & _
"FROM tblToDo WHERE Bruker = '" & Bruker & "'", con2)
con2.Open()
cmdCount.ExecuteNonQuery()
con2.Close()

How do I get get Tall to be the AntallMeldinger ?

reidarT
 
reidarT,

I think you can use ExecuteScalar instead of ExecuteNonQuery:

Tall = cmdCount.ExecuteScalar()

Kerry Moorman
 

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

Back
Top