示例#1
0
        /// <summary>
        /// 获取当前要连接的数据库类型和连接语句
        /// </summary>
        private Fabrics.Schema GetSchema()
        {
            Fabrics.Schema schema = null;
            switch (tcDatabase.SelectedIndex)
            {
            case 0:
                schema = new Fabrics.Schema(accessConn1.ConnectionString, Model.Database.DatabaseType.Access);
                break;

            case 2:
                schema = new Fabrics.Schema(mySqlConn1.ConnectionString, Model.Database.DatabaseType.MySql);
                break;

            case 1:
            default:
                schema = new Fabrics.Schema();
                schema.ConnectionString = sqlConn1.ConnectionString;

                if (sqlConn1.IsSql2005)
                {
                    schema.Type = Model.Database.DatabaseType.Sql2005;
                }
                else
                {
                    schema.Type = Model.Database.DatabaseType.Sql2000;
                }
                break;
            }
            return(schema);
        }
示例#2
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     pictureBox1.Visible = true;
     btnConnect.Enabled  = false;
     Fabrics.Schema schema = GetSchema();
     backgroundWorker1.RunWorkerAsync(schema);
 }
示例#3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Fabrics.Schema schema   = e.Argument as Fabrics.Schema;
            Model.Database database = schema.GetSchema();

            if (backgroundWorker1.CancellationPending)
            {
                e.Cancel = true;
            }
            else
            {
                e.Result = database;
            }
        }