Advertisement
Teammasik

bd_script

Sep 11th, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | Cybersecurity | 0 0
  1. public void Straight()
  2.     {
  3.         string mark = "1";
  4.         string vartest = null;
  5.         //string date = DateTime.UtcNow.ToString("dd-MM-yyyy");
  6.         string date = DateTime.UtcNow.ToString("yyyy-MM-dd");
  7.  
  8.         string con = " datasource=localhost;port=3306;username=root;password=root";
  9.         string query = "insert into unityaccess.students (username,usersurname,usergroup,mark,udate) values('" + namefield.text + "','" + surnamefield.text + "','" + groupfield.text + "','" + mark + "','"+ date +"');";
  10.         string query2 = "insert into unityaccess.students (username,usersurname,usergroup,mark,udate) values('" + namefield.text + "','" + surnamefield.text + "','" + groupfield.text + "','" + mark + "',CURRENT_DATE());";
  11.         string query3 = "SELECT test FROM unityaccess.tests WHERE '" + groupfield.text + "' = test";
  12.         MySqlConnection condb = new(con);
  13.         MySqlCommand cmdNewdb = new MySqlCommand(query3, condb);
  14.         try
  15.         {
  16.             condb.Open();
  17.             MySqlDataReader Reader = cmdNewdb.ExecuteReader();
  18.             if (Reader.HasRows)
  19.             {
  20.                 while (Reader.Read())
  21.                 {
  22.                     vartest = Reader.GetString(0);
  23.                     Debug.Log(vartest);
  24.                 }
  25.             }
  26.             Debug.Log("done");
  27.         }
  28.         catch (Exception ex)
  29.         {
  30.             Debug.Log(ex.Message);
  31.         }
  32.         finally
  33.         {
  34.             condb.Close();
  35.         }
  36.         if (vartest == null)
  37.         {
  38.             string query4 = "insert into unityaccess.tests (test) values('" + groupfield.text + "');";
  39.             MySqlCommand cmddbNewTest = new MySqlCommand(query4, condb);
  40.             try
  41.             {
  42.                 condb.Open();
  43.                 MySqlDataReader Reader = cmddbNewTest.ExecuteReader();
  44.                 Debug.Log("done v2");
  45.             }
  46.             catch (Exception ex)
  47.             {
  48.                 Debug.Log(ex.Message);
  49.             }
  50.             finally
  51.             {
  52.                 condb.Close();
  53.             }
  54.         }
  55.  
  56.         MySqlCommand cmddb = new MySqlCommand(query, condb);
  57.         try
  58.         {
  59.             condb.Open();
  60.             MySqlDataReader Reader = cmddb.ExecuteReader();
  61.             Debug.Log("written");
  62.         }
  63.         catch (Exception ex)
  64.         {
  65.             Debug.Log(ex.Message);
  66.         }
  67.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement