示例#1
0
        public string SqlStatement()
        {
            string result = DatabaseNameSize.SqlStatement();

            return(result);
            // TODO: add assertions to method DatabaseNameSizeTest.SqlStatement()
        }
示例#2
0
        /// <summary>
        /// Gets the size and name of the database.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>the size and name of the database</returns>
        public List <DatabaseNameSize> GetDatabaseNameSize(string database)
        {
            this.ExecuteUseDatabase("master");
            List <DatabaseNameSize> results = new List <DatabaseNameSize>();
            DatabaseNameSize        resultrow;
            string sqlString = DatabaseNameSize.SqlStatement();

            sqlString = string.Format("EXEC sp_executesql @statement = N'{0}'", sqlString.Replace("'", "''"));

            using (SqlConnection connection = new SqlConnection(this.ConnectionString))
                using (SqlCommand command = new SqlCommand(sqlString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            resultrow = new DatabaseNameSize(
                                reader.GetString(reader.GetOrdinal("DatabaseName")),
                                reader.GetString(reader.GetOrdinal("LogicalName")),
                                reader.GetString(reader.GetOrdinal("PhysicalName")),
                                reader.GetInt32(reader.GetOrdinal("Size_MB")));

                            results.Add(resultrow);
                        }
                    }

                    connection.Close();
                }

            return(results);
        }
示例#3
0
        public DatabaseNameSize Constructor(
            string databaseName,
            string logicalName,
            string physicalName,
            int sizeMB
            )
        {
            DatabaseNameSize target
                = new DatabaseNameSize(databaseName, logicalName, physicalName, sizeMB);

            return(target);
            // TODO: add assertions to method DatabaseNameSizeTest.Constructor(String, String, String, Int32)
        }