private void InitializeDoctors() { String username = dbSettings.GetUsername(); String password = dbSettings.GetPassword(); String dbname = "udc_database"; String myConnection = "datasource=localhost;database=" + dbname + ";port=3306;username="******";password="******"Success"); } catch (Exception e) { Console.WriteLine("Connection Failed"); } try { MySqlCommand command = myConn.CreateCommand(); command.CommandText = "select * from doctors"; myConn.Open(); reader = command.ExecuteReader(); while (reader.Read()) { drListBox.Items.Add(reader["name"].ToString()); } myConn.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public AppointmentModel() { this.appointments = new AppointmentList(); this.filteredAppointments = new AppointmentList(); this.views = new List <ListView>(); String username = dbSettings.GetUsername(); String password = dbSettings.GetPassword(); String dbname = "udc_database"; String myConnection = "datasource=localhost;database=" + dbname + ";port=3306;username="******";password="******"Success"); } catch (Exception e) { Console.WriteLine("Connection Failed"); } }
private void loginBtn_Click(object sender, EventArgs e) { String username = dbSettings.GetUsername(); String password = dbSettings.GetPassword(); String dbname = "udc_database"; String myConnection = "datasource=localhost;database=" + dbname + ";port=3306;username="******";password="******"Please enter username and/or password."); } else { try { MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand("select * from doctors where doctorid = '" + this.username.Text + "' and password = '******';", myConn); MySqlDataReader reader; myConn.Open(); reader = SelectCommand.ExecuteReader(); int count = 0; while (reader.Read()) { count += 1; } if (count == 1) //if there is exactly one result from database, it means the username and password matched { loginPanel.Hide(); this.doctorName.Text = reader["name"].ToString(); } else { MessageBox.Show("Incorrect username and/or password."); } } catch (Exception e1) { MessageBox.Show(e1.Message); } } UpdateDoctor(); Update(); }