vendredi 31 juillet 2015

Insufficient parameters supplied to the command

In my query in Sqlite database I got the error of insufficient parameters supplied, like my title topic. I really don't understand what is wrong in my code:

SQLiteCommand command = new SQLiteCommand(@"INSERT INTO Fixtures (data, matchday, homeTeamName, awayTeamName, 
                goalsHomeTeam, goalsAwayTeam, status, result, link_self, link_soccerSeason, link_homeTeam, link_awayTeam, caption) 
                VALUES (@data, @matchday, @homeTeamName, @awayTeamName, @goalsHomeTeam, @goalsAwayTeam, @status, @result, @link_self, 
                @link_soccerSeason, @link_homeTeam, @link_awayTeam, @caption)", Database.m_dbConnection);

this is the line that cause the exception:

 command.ExecuteNonQuery();

UPDATE FULL CODE

 foreach (var fixture in obj.fixtures)
            {
                SQLiteCommand command = new SQLiteCommand(@"INSERT INTO Fixtures (data, matchday, homeTeamName, awayTeamName, 
                goalsHomeTeam, goalsAwayTeam, status, result, link_self, link_soccerSeason, link_homeTeam, link_awayTeam, caption) 
                VALUES (@data, @matchday, @homeTeamName, @awayTeamName, @goalsHomeTeam, @goalsAwayTeam, @status, @result, @link_self, 
                @link_soccerSeason, @link_homeTeam, @link_awayTeam, @caption)", Database.m_dbConnection);
                try
                {
                    command.ExecuteNonQuery();

                    command.Parameters.Add("@data", DbType.Date).Value = fixture.date;
                    command.Parameters.Add("@matchday", DbType.String).Value = fixture.matchday;
                    command.Parameters.Add("@homeTeamName", DbType.String).Value = fixture.homeTeamName;
                    command.Parameters.Add("@awayTeamName", DbType.String).Value = fixture.awayTeamName;
                    command.Parameters.Add("@goalsHomeTeam", DbType.String).Value = fixture.result.goalsHomeTeam;
                    command.Parameters.Add("@goalsAwayTeam", DbType.String).Value = fixture.result.goalsAwayTeam;
                    command.Parameters.Add("@status", DbType.String).Value = fixture.status;
                    command.Parameters.Add("@result", DbType.String).Value = fixture.result.goalsHomeTeam + " - " + fixture.result.goalsAwayTeam;
                    command.Parameters.Add("@link_self", DbType.String).Value = fixture._links.self.href;
                    command.Parameters.Add("@link_soccerSeason", DbType.String).Value = fixture._links.soccerseason.href;
                    command.Parameters.Add("@link_homeTeam", DbType.String).Value = fixture._links.homeTeam.href;
                    command.Parameters.Add("@link_awayTeam", DbType.String).Value = fixture._links.awayTeam.href;
                    command.Parameters.Add("@caption", DbType.String).Value = campionato;

                }
                catch (Exception ex)
                {
                    Console.WriteLine("Attenzione: " + ex.ToString());
                }

Aucun commentaire:

Enregistrer un commentaire