Esempio n. 1
0
        /// <summary>
        /// 针对不同数据库 创建不同的连接对象
        /// </summary>
        public static void findConn(string strDBType,ConnectionInfo connInfo)
        {
            if (strDBType == "SQL Server2005/2008")
            {

                if (sqlCon == null) {

                    sqlCon = getMssqlConn(connInfo);
                }

            }
            else if (strDBType == "MySql")
            {

                IConnection<MySqlConnection> con = DBFactory.CreateConnnection<MySqlConnection>();

                mysqlCon = con.CreateConn(connInfo);

                con.OpenConn(mysqlCon);
            }
            else {

                return;
            }
        }
Esempio n. 2
0
        public override void DeleteObject(ConnectionInfo conn, string objName)
        {
            SqlConnection sqlCon = Provider.getMssqlConn(conn);

                    IDatabaseManage<SqlConnection> dbManage = DBFactory.CreateDatabaseManage<SqlConnection>();

                    dbManage.DelDatabase(sqlCon, objName );
        }
Esempio n. 3
0
        public void CreateObject(ConnectionInfo conn, string dbName, string tableName, ColumnInfo column)
        {
            SqlConnection sqlCon = Provider.getMssqlConn(conn);

            IColumnManage<SqlConnection> columnManage = DBFactory.CreateColumnManage<SqlConnection>();

            columnManage.AddColumn(sqlCon, dbName, tableName, column);
        }
Esempio n. 4
0
        //数据库备份
        public void BackupDataBase(string dbName,ConnectionInfo conn,string fileFullName)
        {
            SqlConnection sqlCon = Provider.getMssqlConn(conn);

                IDatabaseManage<SqlConnection> dbManage = DBFactory.CreateDatabaseManage<SqlConnection>();

                dbManage .BackupDatabase(sqlCon ,dbName ,fileFullName);
        }
Esempio n. 5
0
        public ConnectionInfo getConnInfo()
        {
            ConnectionInfo connInfo = new ConnectionInfo();
            connInfo.Server = Session["Server"].ToString();
            connInfo.UserName = Session["UserName"].ToString();
            connInfo.Pwd = Session["Pwd"].ToString();

            return connInfo;
        }
Esempio n. 6
0
        public bool DeleteObject(ConnectionInfo conn, string objType, string dbName, string tableName, string objName)
        {
            if (objType == "folder_col")
            {

                    SqlConnection sqlCon = Provider.getMssqlConn(conn);

                    IColumnManage<SqlConnection> colManage = DBFactory.CreateColumnManage<SqlConnection>();

                    DataTable dt=colManage.GetAllColumns(sqlCon, dbName, tableName);

                    if (dt.Rows.Count > 1) {

                        colManage.DelColumn(sqlCon, dbName, tableName, objName);
                        return true;
                    }

            }

            return false;
        }
Esempio n. 7
0
        public override void DeleteObject(ConnectionInfo conn, string objType, string dbName, string objName)
        {
            if (objType == "folder_table")
            {

                    SqlConnection sqlCon = Provider.getMssqlConn(conn);

                    ITableManage<SqlConnection> tableManage = DBFactory.CreateTableManage<SqlConnection>();

                    tableManage.DelTable(sqlCon, dbName, objName);
            }
            else if (objType == "folder_view")
            {

                    SqlConnection sqlCon = Provider.getMssqlConn(conn);

                    IViewManage<SqlConnection> viewManage = DBFactory.CreateViewManage<SqlConnection>();

                    viewManage.DelView(sqlCon, dbName, objName);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 获得数据库资源信息列表
        /// </summary>
        /// <param name="strDBType">数据库类型</param>
        /// <param name="connInfo">连接实体</param>
        /// <returns></returns>
        public static IList<DataBaseInfo> findDBManage(string strDBType, ConnectionInfo connInfo)
        {
            if (sqlCon == null) {

                findConn(strDBType, connInfo);
            }

            if (strDBType == "SQL Server2005/2008")
            {

                return findDBManage_Mssql();
            }
            else if (strDBType == "MySql")
            {

                return findDBManage_Mysql();
            }

            else
            {

                return null;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 获得数据库名称
        /// </summary>
        /// <param name="strDBType">数据库类型:SqlServer2005/2008、Mysql</param>
        /// <param name="connInfo">连接实体</param>
        /// <returns>数据集</returns>
        public static DataSet getDBList(string strDBType,ConnectionInfo connInfo)
        {
            DataSet ds = null;

            try
            {
                if (sqlCon == null)
                {

                    findConn(strDBType, connInfo);
                }

                ds = new DataSet();

                if (strDBType == "SQL Server2005/2008")
                {

                    IDatabaseManage<SqlConnection> dbManage = DBFactory.CreateDatabaseManage<SqlConnection>();
                    ds = dbManage.GetAllDatabase(sqlCon);
                }
                else if (strDBType == "MySql")
                {

                    IDatabaseManage<MySqlConnection> dbManage = DBFactory.CreateDatabaseManage<MySqlConnection>();
                    ds = dbManage.GetAllDatabase(mysqlCon);
                }

            }
            catch (Exception ex) { throw ex; }
            return ds;
        }
Esempio n. 10
0
 public virtual void RenameObject(ConnectionInfo connInfo, string oldName, string newName)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 public void RenameObject(ConnectionInfo conn, string objName, string newName, string dbName, string tableName)
 {
     SqlConnection sqlCon = Provider.getMssqlConn(conn);
     IColumnManage<SqlConnection> columnManage = DBFactory.CreateColumnManage<SqlConnection>();
     columnManage.RenameColumn(sqlCon, dbName, tableName, objName, newName);
 }
Esempio n. 12
0
 public override void RenameObject(ConnectionInfo conn, string objName, string newName, string dbName)
 {
     SqlConnection sqlCon = Provider.getMssqlConn(conn);
         ITableManage<SqlConnection> tableManage = DBFactory.CreateTableManage<SqlConnection>();
         tableManage.RenameTable(sqlCon, dbName, objName, newName);
 }
Esempio n. 13
0
        //数据库是否存在
        public bool IsExistDataBase(string dbName,ConnectionInfo conn)
        {
            SqlConnection sqlCon = Provider.getMssqlConn(conn);

                IDatabaseManage<SqlConnection> dbManage = DBFactory.CreateDatabaseManage<SqlConnection>();

                return dbManage.IsExist(sqlCon, dbName);
        }
Esempio n. 14
0
        /// <summary>
        /// 获得Mysql数据库的连接对象
        /// </summary>
        /// <param name="connInfo"></param>
        /// <returns></returns>
        internal static MySqlConnection getMysqlConn(ConnectionInfo connInfo)
        {
            IConnection<MySqlConnection> con = DBFactory.CreateConnnection<MySqlConnection>();

            mysqlCon = con.CreateConn(connInfo);

            con.OpenConn(mysqlCon);

            return mysqlCon;
        }
Esempio n. 15
0
        /// <summary>
        /// 获得Sql Server数据库的连接对象
        /// </summary>
        /// <param name="strDBType">数据库类型</param>
        /// <param name="connInfo">连接实体</param>
        /// <returns></returns>
        internal static SqlConnection getMssqlConn(ConnectionInfo connInfo)
        {
            IConnection<SqlConnection> con = DBFactory.CreateConnnection<SqlConnection>();

            sqlCon = con.CreateConn(connInfo);

            con.OpenConn(sqlCon);

            return sqlCon;
        }
Esempio n. 16
0
 public virtual void CreateObject(ConnectionInfo connInfo, string nodeName)
 {
     throw new NotImplementedException();
 }
Esempio n. 17
0
 public virtual void DeleteObject(ConnectionInfo connInfo, string nodeType, string parentNodeName, string nodeName)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
        //查看脚本
        public override string ShowScript(string dbName, ConnectionInfo conn, string name)
        {
            SqlConnection sqlCon = Provider.getMssqlConn(conn);

            IViewManage<SqlConnection> tableManage = DBFactory.CreateViewManage<SqlConnection>();
            string str= tableManage.ShowView(sqlCon, dbName, name);

            //对str进行/r/n处理
            str =str.Replace("\r\n", " ");

            return str;
        }
Esempio n. 19
0
 public virtual string ShowScript(string dbName, ConnectionInfo connInfo, string name)
 {
     throw new NotImplementedException();
 }
Esempio n. 20
0
        //查看表数据
        public DataTable ShowTableData(string dbName, ConnectionInfo conn, string table)
        {
            SqlConnection sqlCon = Provider.getMssqlConn(conn);

            ITableManage<SqlConnection> tableManage = DBFactory.CreateTableManage<SqlConnection>();
            return tableManage.ShowTableData(sqlCon, dbName, table);
        }