/// <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); }
private void btnConnect_Click(object sender, EventArgs e) { pictureBox1.Visible = true; btnConnect.Enabled = false; Fabrics.Schema schema = GetSchema(); backgroundWorker1.RunWorkerAsync(schema); }
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; } }