Advertisement
angryatti

C# - Query from MySQL

May 20th, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1.  string csatlakozasiadatok = @"server=localhost;userid=root;password='';database=kozlekedes"; //your database
  2.  
  3.             var connect = new MySqlConnection(csatlakozasiadatok); //your connection with var connect
  4.             connect.Open();
  5.             MySqlDataReader Reader; //reader for the values
  6.  
  7.    
  8.             string leker = "SELECT `nev` FROM `metro` ORDER BY `nev` ; "; //SELECT name from metro table order by name
  9.             var cmd = new MySqlCommand(leker,connect);
  10.             cmd.CommandText = leker;
  11.             Reader = cmd.ExecuteReader();
  12.             while (Reader.Read())
  13.             {
  14.                 string thisrow = "";
  15.                 for (int i = 0; i < Reader.FieldCount; i++)
  16.                     thisrow += Reader.GetValue(i).ToString();
  17.                 lbAdat1.Items.Add(thisrow);
  18.             }
  19.             connect.Close();
  20.  
  21. //it's half-english and half-hungarian #sample for MySQL connection...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement