Bonsoir,

Je suis tout à fait débutant et j'aimerai connaitre votre avis par rapport à mon code suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
req = "SELECT p.refco, v.refci FROM ccm_countries p INNER JOIN ccm_cities v ON(v.refco = p.refco) WHERE p.cname = '" + ccountry.Text + "' AND v.cname = '" + ccity.Text + "';";
 
SQLiteConnection oConn = new SQLiteConnection(connect);
oConn.Open();
SQLiteDataAdapter sData = new SQLiteDataAdapter(req, oConn);                    
DataSet oData = new DataSet(req);                    
sData.Fill(oData, req);
MessageBox.Show(oData.Tables[req].Rows[0][0].ToString());
MessageBox.Show(oData.Tables[req].Rows[0][1].ToString());
 
req2 = "SELECT refs FROM ccm_specs WHERE sname = '" + pspec.Text + "';";
SQLiteDataAdapter sData2 = new SQLiteDataAdapter(req2, oConn);
DataSet oData2 = new DataSet(req2);
sData2.Fill(oData2, req2);
MessageBox.Show(oData2.Tables[req2].Rows[0][0].ToString());
MessageBox.Show(oData.Tables[req].Rows[0][1].ToString());
oConn.Close();
le but de ce code est d'afficher en message :
- ID du pays
- ID de ville
- ID de spécialité

Ma question est ce que ma façon de faire cette opération, ayant deux SQLitedataAdapter et deux DataSet est bonne ou pas.