Advertisement
BaSs_HaXoR

MySQL Connection C#

Feb 26th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. MySQL Connection For C#
  2.  
  3.   try
  4.             {
  5.                 string myConnection = "datasource=db4free.net;Port=3306;username=username;password=password;database=database";
  6.                 MySqlConnection MyConn = new MySqlConnection(myConnection);
  7.  
  8.                 MySqlCommand SelectCommand = new MySqlCommand("SELECT * From Public WHERE Username='" + this.UsernameTextBox.Text + "' AND Password='" + this.PasswordTextBox.Text + "' ;", MyConn); //+ "' AND HWID='" + "PUBLIC" + "';");
  9.  
  10.                 MySqlDataReader myReader;
  11.                 MyConn.Open();
  12.                 myReader = SelectCommand.ExecuteReader();
  13.                 int count = 0;
  14.                 while (myReader.Read())
  15.                 {
  16.                     count = count + 1; //checks for duplicate users
  17.                 }
  18.                 if (count == 1)
  19.                 {
  20.                     MessageBox.Show("LOG ME THE FUCK IN NAQQUAA I PAID");
  21.                 }
  22.                 else if (count > 1)
  23.                 {
  24.                     MessageBox.Show("Duplicate Username and password... Access denied");
  25.                 }
  26.                 else
  27.                 {
  28.                     MessageBox.Show("Username/password is NOT Correct... Please try again");
  29.                 }
  30.                 MyConn.Close();
  31.             }
  32.             catch (Exception ex)
  33.             {
  34.                 MessageBox.Show("SHIT..." + Environment.NewLine + ex.Message);
  35.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement