dimanche 9 août 2015

SQLite: Issues with parameters

I'm having a small issue with SQLite in a WPF application and I can't seem to figure out the reason.

Here's the code:

        string today = ConvertToday(DateTime.Today.DayOfWeek.ToString());

        SQLiteCommand command1 = new SQLiteCommand("SELECT Set_Dif_Multi FROM Diffusion WHERE @today = 1", DB_Connection);
        command1.CommandType = CommandType.Text;
        command1.Parameters.Add(new SQLiteParameter("@today", today));
        DB_Connection.Open();
        SQLiteDataReader dr1 = command1.ExecuteReader();
        while (dr1.Read())
        {
             stuff();

ConvertToday() is just a simple switch case method to translate DateTime.Today.DayOfWeek in french. I've checked and analyzed pretty much everything step by step and right before I start the DataReader I can see the parameter as "Dimanche" (Sunday). But no output at all unless I replace @today by "Dimanche" in the command directly, in which case it works fine.

(Just to be clear, the 'while' does not execute "stuff()")

Any help would be appreciated :)

Have a good day

Aucun commentaire:

Enregistrer un commentaire