E
Etayki
Hi!
I am trying to find the number of records stored in my table within a
MS SQL database.
This is part of a Console Application.
Here is my code:
Sub RecordCount()
Dim cmd2 As New System.Data.SqlClient.SqlCommand("SELECT
COUNT(*) FROM Keyword", conn)
Dim count As Integer
count = cmd2.ExecuteNonQuery()
Console.WriteLine(count)
End Sub
When I run this, the console displays "-1".
How do I write the code in such a way that I can execute the SQL
command
SELECT COUNT(*) FROM Keyword
and store the result in a variable?
Thanks,
Etay
I am trying to find the number of records stored in my table within a
MS SQL database.
This is part of a Console Application.
Here is my code:
Sub RecordCount()
Dim cmd2 As New System.Data.SqlClient.SqlCommand("SELECT
COUNT(*) FROM Keyword", conn)
Dim count As Integer
count = cmd2.ExecuteNonQuery()
Console.WriteLine(count)
End Sub
When I run this, the console displays "-1".
How do I write the code in such a way that I can execute the SQL
command
SELECT COUNT(*) FROM Keyword
and store the result in a variable?
Thanks,
Etay