kescott
Posts: 49
|
Posted: 11/03/2008, 3:09 PM |
|
How do I count the number of rows I added to my database? I'm have trouble compiling in CodeCharge. For some reason Console.WriteLine() method has no effect.
:)
I was thinking I could do the following:
//----
string connectionString = GetConnectionString();
using (SqlConnection sourceConnection = new SqlConnection(connectionString))
{
sourceConnection.Open();
SqlCommand commandRowCount = new SqlCommand(
"SELECT COUNT(*) FROM Employees;", sourceConnection);
long countStart = System.Convert.ToInt32(
commandRowCount.ExecuteScalar());
Console.WriteLine("Starting row count = {0}", countStart);
long countEnd = System.Convert.ToInt32(
commandRowCount.ExecuteScalar());
Console.WriteLine("Ending row count = {0}", countEnd);
Console.WriteLine("{0} rows were added.", countEnd - countStart);
//-----
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|