Click here to Skip to main content
16,022,296 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Quelle est la syntaxe pour récuperer des items de la table avec 2 et plus paramètres

What I have tried:

string jourV="Samedi";
string rangV="Salle";
string requete="Select * from Table WHere Jour= ? And Rang=?";
conn.Query.(requete, jourV,rangV).ToList();
Posted
Updated 13-Jul-24 22:53pm

1 solution

Try this:
C#
string jourV="Samedi";
string rangV="Salle";
string requete="SELECT * FROM MyTable WHERE Jour = @J AND Rang = @R";
using (SqliteConnection con = new SqliteConnection("Data Source=MyDB.db"))
   {
   con.Open();
   using (SqliteCommand cmd = new SqliteCommand(requete, con))
      {
      cmd.Parameters.AddWithValue("@J", jourV);
      cmd.Parameters.AddWithValue("@R", rangV);
      using (SqliteDataReader reader = cmd.ExecuteReader())
         {
         while (reader.Read())
            {
            ...
            } 
         }
      }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900