Exemplo n.º 1
0
 public List <string> ColumnNames()
 {
     columnNames.Clear();
     foreach (string s in tableNames)
     {
         using (SqlConnection connection = new SqlConnection(ModelDal.GetConnectionString()))
         {
             connection.Open();
             using (SqlCommand command = new SqlCommand("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + s + "'", connection))
             {
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         for (int i = 0; i < reader.FieldCount; i++)
                         {
                             columnNames.Add(s.ToString() + ":  " + reader.GetValue(i).ToString());
                         }
                     }
                 }
             }
         }
     }
     return(columnNames);
 }
Exemplo n.º 2
0
 public List <string> RowsNumber()
 {
     rowsNumber.Clear();
     foreach (string s in tableNames)
     {
         using (SqlConnection connection = new SqlConnection(ModelDal.GetConnectionString()))
         {
             connection.Open();
             using (SqlCommand command = new SqlCommand("SELECT COUNT(*) FROM " + s, connection))
             {
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         for (int i = 0; i < reader.FieldCount; i++)
                         {
                             rowsNumber.Add(s.ToString() + ":  " + reader.GetValue(i).ToString());
                         }
                     }
                 }
             }
         }
     }
     return(rowsNumber);
 }
Exemplo n.º 3
0
 public List <string> TableNames()
 {
     tableNames.Clear();
     using (SqlConnection connection = new SqlConnection(ModelDal.GetConnectionString()))
     {
         connection.Open();
         using (SqlCommand command = new SqlCommand("SELECT * FROM TablesOfInterest", connection))
         {
             using (SqlDataReader reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     for (int i = 0; i < reader.FieldCount; i++)
                     {
                         tableNames.Add(reader.GetValue(i).ToString());
                     }
                 }
             }
         }
         return(tableNames);
     }
 }