private void btnLogin_Click(object sender, EventArgs e)
        {
            if (cmbDatabase.SelectedIndex == 0)
            {
                MessageBox.Show("Pilih database!!");
                return;
            }

            string username = txtUsername.Text;
            string password = txtPassword.Text;
            string server   = txtServer.Text;

            FrmMain.jenisDatabase = cmbJenisDatabase.Text;
            if (cmbJenisDatabase.Text == "SQLSERVER")
            {
                koneksiSqlServer      = new LibraryFramework.DatabaseSqlServer.Koneksi(username, password, server, cmbDatabase.Text);
                dataDatabaseSqlServer = new DataDatabaseSqlServer(koneksiSqlServer.Con);
                il.refreshSqlServer(dataDatabaseSqlServer.getTableName(), koneksiSqlServer);
            }
            else
            {
                koneksiMySql      = new LibraryFramework.DatabaseMySql.Koneksi(username, password, server, cmbDatabase.Text);
                dataDatabaseMySql = new DataDatabaseMySql(koneksiMySql.Con);
                il.refreshMySql(dataDatabaseMySql.getTableName(cmbDatabase.Text), koneksiMySql, cmbDatabase.Text);
            }
            Close();
        }
Exemple #2
0
 public void refreshSqlServer(DataTable dtb, LibraryFramework.DatabaseSqlServer.Koneksi kon)
 {
     lstTable.Items.Clear();
     foreach (DataRow row in dtb.Rows)
     {
         lstTable.Items.Add(row["table_name"].ToString());
     }
     this.konSqlServer      = kon;
     dataDatabaseSqlServer  = new DataDatabaseSqlServer(kon.Con);
     gvfSchema              = new GridViewFunction(dgvSchema);
     lstTable.SelectedIndex = 0;
 }
        private void btnSambungkan_Click(object sender, EventArgs e)
        {
            if (!CommonFunction.validasi(cmbJenisDatabase, txtServer, txtUsername, txtPassword))
            {
                return;
            }

            string username = txtUsername.Text;
            string password = txtPassword.Text;
            string server   = txtServer.Text;

            if (cmbJenisDatabase.Text == "SQLSERVER")
            {
                koneksiSqlServer = new LibraryFramework.DatabaseSqlServer.Koneksi(username, password, server, "master");
                if (!koneksiSqlServer.Login())
                {
                    return;
                }

                dataDatabaseSqlServer = new DataDatabaseSqlServer(koneksiSqlServer.Con);
                CommonFunction.setCombo(cmbDatabase, dataDatabaseSqlServer.getDatabase(), "database_name", "database_name", 0, 0);
            }
            else
            {
                koneksiMySql = new LibraryFramework.DatabaseMySql.Koneksi(username, password, server, "test");
                if (!koneksiMySql.Login())
                {
                    return;
                }

                dataDatabaseMySql = new DataDatabaseMySql(koneksiMySql.Con);
                CommonFunction.setCombo(cmbDatabase, dataDatabaseMySql.getDatabase(), "database", "database", 0, 0);
            }
            cmbJenisDatabase.Enabled = false;
            txtServer.Enabled        = false;
            txtUsername.Enabled      = false;
            txtPassword.Enabled      = false;
        }