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
| private void Form1_Load(object sender, EventArgs e)
{
string strConnection = "Data Source=localhost; Integrated Security=SSPI;Initial Catalog=test";
SqlConnection myConnection = new SqlConnection(strConnection);
try
{
//Ouverture de connection
myConnection.Open();
//Requete de selection des entregistrement
string strSelect = "Select * From personne";
SqlDataAdapter myAdapter = new SqlDataAdapter(strSelect, myConnection);
DataSet myDataset = new DataSet();
myAdapter.Fill(myDataset, "personne");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
myConnection.Close();
}
} |
Partager