SHARE
TWEET

Untitled

a guest Jun 7th, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.             string user = lblUsername.Text;
  3.             string pass = lblPass.Text;
  4.             string myConn = "datasource=localhost;database=posbase;port=3306;username=root;password=root;";
  5.             MySqlConnection Conn = new MySqlConnection(myConn);
  6.             Conn.Open();
  7.             //i had 2 make a pun to make this work!!
  8.             string croofname = "";
  9.             string croolname = "";
  10.             MySqlCommand getme = new MySqlCommand();
  11.             getme.CommandText = "select * from accounttbl where userid = ?userid";
  12.             getme.Connection = Conn;
  13.             getme.Parameters.AddWithValue("?userid", user.Trim());
  14.             MySqlDataReader read;
  15.  
  16.             read = getme.ExecuteReader();
  17.             while (read.Read())
  18.             {
  19.                 croofname = read.GetString("fname").ToString();
  20.                 croolname = read.GetString("lname").ToString();
  21.             }
  22.             Conn.Close();
  23.             Conn.Open();
  24.  
  25.             MySqlCommand cmd = new MySqlCommand();
  26.             cmd.CommandText = "Select userid, pass, usertype from accounttbl where userid = ?userid and pass =?password";
  27.             cmd.Parameters.AddWithValue("?userid", user.Trim());
  28.             cmd.Parameters.AddWithValue("?password", pass.Trim());
  29.             cmd.Connection = Conn;
  30.  
  31.  
  32.             MySqlCommand cmd2 = new MySqlCommand();
  33.             cmd2.Connection = Conn;
  34.             cmd2.CommandText = "update posbase.usersession set user=?user WHERE id=?id";
  35.             cmd2.Parameters.AddWithValue("?user", user.Trim());
  36.             cmd2.Parameters.AddWithValue("?id", 1);
  37.             cmd2.ExecuteNonQuery();
  38.             MySqlCommand cmd3 = new MySqlCommand();
  39.             cmd3.Connection = Conn;
  40.             cmd3.CommandText = "insert into loginhistory(user, time, date, crewname) value(?user, ?time, ?date, ?crewname)";
  41.             cmd3.Parameters.AddWithValue("?user", user.Trim());
  42.             cmd3.Parameters.AddWithValue("?time", DateTime.Now.ToShortTimeString());
  43.             cmd3.Parameters.AddWithValue("?date", DateTime.Now.ToShortDateString());
  44.             cmd3.Parameters.AddWithValue("?crewname", croofname + " " + croolname);
  45.             cmd3.ExecuteNonQuery();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top