Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string connStr ="server=10.241.0.1;user=sqlhazi;database=sqlbeadando;port=3306;password=ntRaEXZ0qbjm";
- MySqlConnection conn = new MySqlConnection(connStr);
- var result= new List<string>();
- try{
- Console.WriteLine("Connecting to MySQL:");
- conn.Open();
- //itt használom az adatbázis lekérdezést
- string sql = "select question from Question where exam_id = 0 order by rand() limit 6;"; //sqles parancsot ide
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- MySqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- //Console.WriteLine((string)reader["question"]);
- result.Add((string)reader["question"]);
- }
- reader.Close();
- }catch (Exception ex){
- Console.WriteLine(ex.ToString());
- }
- conn.Close();
- Console.WriteLine("Done...");
- return result;
- }
- // 1 tárgy
- public List<string> get2(){
- string connStr ="server=10.241.0.1;user=sqlhazi;database=sqlbeadando;port=3306;password=ntRaEXZ0qbjm";
- MySqlConnection conn = new MySqlConnection(connStr);
- var result= new List<string>();
- try{
- Console.WriteLine("Connecting to MySQL:");
- conn.Open();
- //itt használom az adatbázis lekérdezést
- string sql = "select question from Question where exam_id = 1 order by rand() limit 6;"; //sqles parancsot ide
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- MySqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- //Console.WriteLine((string)reader["question"]);
- result.Add((string)reader["question"]);
- }
- reader.Close();
- }catch (Exception ex){
- Console.WriteLine(ex.ToString());
- }
- conn.Close();
- Console.WriteLine("Done...");
- return result;
- }
- //targy 3
- public List<string> get3(){
- string connStr ="server=10.241.0.1;user=sqlhazi;database=sqlbeadando;port=3306;password=ntRaEXZ0qbjm";
- MySqlConnection conn = new MySqlConnection(connStr);
- var result= new List<string>();
- try{
- Console.WriteLine("Connecting to MySQL:");
- conn.Open();
- //itt használom az adatbázis lekérdezést
- string sql = "select question from Question where exam_id = 2 order by rand() limit 6;"; //sqles parancsot ide
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- MySqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- //Console.WriteLine((string)reader["question"]);
- result.Add((string)reader["question"]);
- }
- reader.Close();
- }catch (Exception ex){
- Console.WriteLine(ex.ToString());
- }
- conn.Close();
- Console.WriteLine("Done...");
- return result;
- }
- //targy 4
- public List<string> get4(){
- string connStr ="server=10.241.0.1;user=sqlhazi;database=sqlbeadando;port=3306;password=ntRaEXZ0qbjm";
- MySqlConnection conn = new MySqlConnection(connStr);
- var result= new List<string>();
- try{
- Console.WriteLine("Connecting to MySQL:");
- conn.Open();
- //itt használom az adatbázis lekérdezést
- string sql = "select question from Question where exam_id = 3 order by rand() limit 6;"; //sqles parancsot ide
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- MySqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- //Console.WriteLine((string)reader["question"]);
- result.Add((string)reader["question"]);
- }
- reader.Close();
- }catch (Exception ex){
- Console.WriteLine(ex.ToString());
- }
- conn.Close();
- Console.WriteLine("Done...");
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement