1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
namespace lecteur_mp3
{
public partial class LecteurMP3 : Form
{
string music, music2;
public LecteurMP3()
{
InitializeComponent();
}
string Conx = "Server=localhost;Database=blindtest;User id=etude;password=;";
NpgsqlConnection Cnx = null;
private void buttonChoix_Click(object sender, EventArgs e)
{
Cnx = new NpgsqlConnection(Conx);
Cnx.Open();
using (var Cmd = new NpgsqlCommand())
{
Cmd.Connection = Cnx;
Cmd.CommandText = "SELECT nom from morceau order by random()";
NpgsqlDataReader readernom = Cmd.ExecuteReader();
while (readernom.Read())
{
music = readernom.GetString(0);
music2 = readernom.GetString(1);
}
}
button1.Text = music;
button2.Text = music2;
} |
Partager