20078888

技术前线

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace Model
{
    public class Database
    {
        private bool _connected;
        private string _connectionstring;
        private List<string> _storeprocedures = new List<string>();
        private List<Table> _tables = new List<Table>();
        private DatabaseType _type;
        private List<string> _views = new List<string>();

        public bool Connected
        {
            get
            {
                return this._connected;
            }
            set
            {
                this._connected = value;
            }
        }

        public string ConnectionString
        {
            get
            {
                return this._connectionstring;
            }
            set
            {
                this._connectionstring = value;
            }
        }

        public string DatabaseName
        {
            get
            {
                if (this._type == DatabaseType.Access)
                {
                    OleDbConnection connection = new OleDbConnection(this._connectionstring);
                    return connection.DataSource;
                }
                SqlConnection connection2 = new SqlConnection(this._connectionstring);
                return connection2.Database;
            }
        }

        public List<string> StoreProcedures
        {
            get
            {
                return this._storeprocedures;
            }
            set
            {
                this._storeprocedures = value;
            }
        }

        public List<Table> Tables
        {
            get
            {
                return this._tables;
            }
            set
            {
                this._tables = value;
            }
        }

        public DatabaseType Type
        {
            get
            {
                return this._type;
            }
            set
            {
                this._type = value;
            }
        }

        public List<string> Views
        {
            get
            {
                return this._views;
            }
            set
            {
                this._views = value;
            }
        }

        public enum DatabaseType
        {
            Access,
            Sql2000,
            Sql2005
        }
    }
}

posted on 2010-05-07 17:27  许雪林  阅读(120)  评论(0)    收藏  举报