Ejemplo n.º 1
0
        private void cboDBName_Click(object sender, EventArgs e)
        {
            try
            {
                var sqr = new SqlReader();

                if (txtLogin.Enabled)
                {
                    sqr = new SqlReader(cboSQLServer.Text, "master", txtLogin.Text, txtPassword.Text);
                }
                else
                {
                    sqr = new SqlReader(cboSQLServer.Text, "master");
                }

                using (var tbl = sqr.GetDatabases())
                {
                    cboDBName.Items.Clear();
                    foreach (DataRow r in tbl.Rows)
                    {
                        string s = r["name"].ToString();
                        cboDBName.Items.Add(s.TrimEnd(new char[] { '\\' }));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public FrmTransfer()
 {
     InitializeComponent();
     _exr = new ExcelReader();
     _sqr = new SqlReader();
 }
Ejemplo n.º 3
0
 private void cmdOpenSql_Click(object sender, EventArgs e)
 {
     try
     {
         using (var frm = new FrmConfig())
         {
             frm.ShowDialog();
             if (!frm._status) return;
             if (frm.txtLogin.Enabled)
             {
                 _sqr = new SqlReader(frm.cboSQLServer.Text, frm.cboDBName.Text, frm.txtLogin.Text, frm.txtPassword.Text);
             }
             else
             {
                 _sqr = new SqlReader(frm.cboSQLServer.Text, frm.cboDBName.Text);
             }
         }
         cboSqlTable.Items.Clear();
         cboSqlTable.Text = null;
         foreach (string s in _sqr.GetTable())
         {
             cboSqlTable.Items.Add(s);
         }
         if (cboSqlTable.Items.Count > 0)
         {
             cboSqlTable.SelectedIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }