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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| private void bddedit_Load(object sender, EventArgs e)
{
// Enregistrement de BASS
BassNet.Registration("****", "****");
// Initialisation du périphérique pour PFL
if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_LATENCY, this.Handle, null))
{
// On fait rien pour le moment
}
else
{
// On affiche un MSG d'erreur
MessageBox.Show(this, "Erreur lors de l'initialisation de BASS", "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// On charge la liste des catégorie
OleDbConnection Myconnection = null;
OleDbDataReader dbReader = null;
Myconnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=BDD.rsdb");
dataGridView1.DataSource = null;
// On crée un DataSet
DataSet ds = new DataSet();
OleDbCommand command = Myconnection.CreateCommand();
// On ouvre la connexion
Myconnection.Open();
OleDbCommand cmd = Myconnection.CreateCommand();
cmd.CommandText = "SELECT Nom FROM Catégories";
dbReader = cmd.ExecuteReader();
string Nom;
// On complète la comboBox avec le nom des catégorie
while (dbReader.Read())
{
Nom = (string)dbReader.GetValue(0);
comboBox1.Items.Add(Nom);
}
// On sélectionne le premier Item
comboBox1.SelectedIndex = 0;
// On ferme le dbReader
dbReader.Close();
// La requête en string
String connect = (@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=BDD.rsdb");
String lacmd = ("SELECT Artiste, Titre FROM Musiques WHERE Catégories = '" + comboBox1.SelectedItem + "'");
OleDbDataAdapter adapter = new OleDbDataAdapter(lacmd, connect);
MessageBox.Show(Convert.ToString(adapter));
adapter.Fill(ds, "Musiques");
// On ferme la connexion
Myconnection.Close();
// On rempli le dataGridView
dataGridView1.DataSource = ds.Tables[0];
} |
Partager