Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Straight()
- {
- string mark = "1";
- string vartest = null;
- //string date = DateTime.UtcNow.ToString("dd-MM-yyyy");
- string date = DateTime.UtcNow.ToString("yyyy-MM-dd");
- string con = " datasource=localhost;port=3306;username=root;password=root";
- string query = "insert into unityaccess.students (username,usersurname,usergroup,mark,udate) values('" + namefield.text + "','" + surnamefield.text + "','" + groupfield.text + "','" + mark + "','"+ date +"');";
- string query2 = "insert into unityaccess.students (username,usersurname,usergroup,mark,udate) values('" + namefield.text + "','" + surnamefield.text + "','" + groupfield.text + "','" + mark + "',CURRENT_DATE());";
- string query3 = "SELECT test FROM unityaccess.tests WHERE '" + groupfield.text + "' = test";
- MySqlConnection condb = new(con);
- MySqlCommand cmdNewdb = new MySqlCommand(query3, condb);
- try
- {
- condb.Open();
- MySqlDataReader Reader = cmdNewdb.ExecuteReader();
- if (Reader.HasRows)
- {
- while (Reader.Read())
- {
- vartest = Reader.GetString(0);
- Debug.Log(vartest);
- }
- }
- Debug.Log("done");
- }
- catch (Exception ex)
- {
- Debug.Log(ex.Message);
- }
- finally
- {
- condb.Close();
- }
- if (vartest == null)
- {
- string query4 = "insert into unityaccess.tests (test) values('" + groupfield.text + "');";
- MySqlCommand cmddbNewTest = new MySqlCommand(query4, condb);
- try
- {
- condb.Open();
- MySqlDataReader Reader = cmddbNewTest.ExecuteReader();
- Debug.Log("done v2");
- }
- catch (Exception ex)
- {
- Debug.Log(ex.Message);
- }
- finally
- {
- condb.Close();
- }
- }
- MySqlCommand cmddb = new MySqlCommand(query, condb);
- try
- {
- condb.Open();
- MySqlDataReader Reader = cmddb.ExecuteReader();
- Debug.Log("written");
- }
- catch (Exception ex)
- {
- Debug.Log(ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement