string sql = "SELECT COUNT(*) FROM [DB].[dbo].[myTable]"; SqlCommand cmd = new SqlComman(sql, connectionString); int count = (int)cmd.ExecuteScalar();