1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
private void contacts_Load(object sender, EventArgs e)
{
string requete = "SELECT * FROM table WHERE id='" + int.Parse(textBox.Text)+"'";
//création de la connection
OdbcConnection connection = new OdbcConnection();
//chaine de connection (du type "DSN=monDSN)
string chaineDeConnection = "Dsn=commerce";
//affectation de la chaine de connection à la connection
connection.ConnectionString = chaineDeConnection;
//ouverture de la connection
connection.Open();
OdbcCommand comm = new OdbcCommand(requete, connection);
OdbcDataReader lire = comm.ExecuteReader();
lire.Read();
textBox1.Text = lire.ToString();
} |
Partager