private void btnLogin_Click(object sender, EventArgs e) { String severName = txtSeverName.Text.Trim(); String database = txtDatabase.Text.Trim(); String userId = txtUserId.Text.Trim(); String passwordDB = txtPasswordDB.Text.Trim(); DTO_DBConnect dtoDBConenct = new DTO_DBConnect(severName, database, userId, passwordDB); if (dbConnect.DBConnect(dtoDBConenct)) { MessageBox.Show("Login thành công", "Thông báo"); LoadMenu loadMenu = new LoadMenu(); loadMenu.Load(true); this.Close(); } }
public bool DBConnect(DTO_DBConnect login) { try { String connectionString = @"Data Source=" + login.SeverName + ";Initial Catalog=" + login.Database + ";Persist Security Info=True;" + "User ID=" + login.UserID + ";Password=" + login.Password; connection = new SqlConnection(connectionString); connection.Open(); return(true); } catch (Exception e) { MessageBox.Show(e.ToString()); return(false); } }
public bool DBConnect(DTO_DBConnect dto) { return(dBConnection.DBConnect(dto)); }