Ejemplo n.º 1
0
 public virtual bool Fill(TableSize dataClass)
 {
     try {
         this.TableName = dataClass.TableName;
         this.RowCount  = dataClass.RowCount;
         return(true);
     }
     catch (System.Exception ex) {
         throw new System.ApplicationException("Error in the Auto-Generated: TableSize.Fill(TableSize) Method", ex);
     }
 }
Ejemplo n.º 2
0
        public static TableSize[] GetDatabaseTableListWithRowCount(ConnectionData connData, string filter)
        {
            string tableName;
            string schemaOwner;

            string[]      tables = GetDatabaseTableList(connData, filter);
            TableSize[]   sizes  = new TableSize[tables.Length];
            SqlConnection conn   = SqlSync.Connection.ConnectionHelper.GetConnection(connData.DatabaseName, connData.SQLServerName, connData.UserId, connData.Password, connData.AuthenticationType, connData.ScriptTimeout);

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                conn.Open();

                for (int i = 0; i < tables.Length; i++)
                {
                    ExtractNameAndSchema(tables[i], out tableName, out schemaOwner);
                    try
                    {
                        if (conn.State == ConnectionState.Closed)
                        {
                            conn.Open();
                        }
                        cmd.CommandText = "sp_spaceused [" + schemaOwner + "." + tableName + "]";
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            reader.Read();
                            sizes[i]           = new TableSize();
                            sizes[i].TableName = schemaOwner + "." + reader.GetString(0);
                            sizes[i].RowCount  = Int32.Parse(reader[1].ToString());
                        }
                    }
                    catch
                    {
                        sizes[i]           = new TableSize();
                        sizes[i].TableName = schemaOwner + "." + tableName;
                        sizes[i].RowCount  = -1;
                    }
                }
            }
            catch
            {
            }
            finally
            {
                conn.Close();
            }
            return(sizes);
        }