0

This is really driving me crazy... I do not see what my issue is.

data[] is an array of strings already specified.

private void updateDB(string[] data)
     {
         m_dbConnection = new SQLiteConnection("Data Source=MyGameList.sqlite;Version=3;");
         m_dbConnection.Open();

         SQLiteCommand command = new SQLiteCommand(@"Update gamelist set Name=@name, directory=@directory, url=@url, graphics=@graphics, graphicDrop=@graphicDrop, adapter=@adapter,
                                                    adapterDrop=@adapterDrop, resolution=@resolution, resolutionDrop=@resolutionDrop, x=@xr, y=@yr, windowBorderless=@windowBorderless, 
                                                    OvrService=@OvrService, Aero=@Aero, Notes=@Notes where Name=@name", m_dbConnection);

         command.Parameters.Add(new SQLiteParameter("@name", data[0]));
         command.Parameters.Add(new SQLiteParameter("@directory", data[1]));
         command.Parameters.Add(new SQLiteParameter("@url", data[2]));
         command.Parameters.Add(new SQLiteParameter("@graphics", data[3]));
         command.Parameters.Add(new SQLiteParameter("@graphicDrop", data[4]));
         command.Parameters.Add(new SQLiteParameter("@adapter", data[5]));
         command.Parameters.Add(new SQLiteParameter("@adapterDrop", data[6]));
         command.Parameters.Add(new SQLiteParameter("@resolution", data[7]));
         command.Parameters.Add(new SQLiteParameter("@resolutionDrop", data[8]));
         command.Parameters.Add(new SQLiteParameter("@xr", data[9]));
         command.Parameters.Add(new SQLiteParameter("@yr", data[10]));
         command.Parameters.Add(new SQLiteParameter("@windowBoderless", data[11]));
         command.Parameters.Add(new SQLiteParameter("@OvrService", data[12]));
         command.Parameters.Add(new SQLiteParameter("@Aero", data[13]));
         command.Parameters.Add(new SQLiteParameter("@Notes", data[14]));

         try
         {
             command.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
         m_dbConnection.Close();
     }    

I checked the spelling and format of each parameter and it still gives me:

Unknown Error:

Insufficient Parameters supplied to the command.

Thanks for any insight

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
bill
  • 711
  • 1
  • 8
  • 19
  • 3
    `@windowBorderless` is the parameter in your command you have `@windowBoderless` in your parameter list. It is a simple typo – Habib Aug 25 '14 at 13:45
  • Apparently I'm blind to the letter R because I looked over each one for about 30 minutes. – bill Aug 25 '14 at 13:46
  • Just for a tip, What I did was to select each parameter in the command and use Find to find the exact instances of that text in your code. For the `@windowBorderless`, I couldn't find any other matching instance in the code. Just another useful usage of Ctrl + F – Habib Aug 25 '14 at 13:48
  • I should have done that. Thanks for your quick help, and sorry to waste your time with such a simple issue. – bill Aug 25 '14 at 13:50
  • 1
    one more thing to add, you should rarely need to to re-throw exception like you are doing in your code, you can simply use `throw` keyword, that will keep the stack trace intact. See [Throwing Exceptions best practices](http://stackoverflow.com/questions/22623/throwing-exceptions-best-practices). Plus look at the exception object in debugger window, that might give you the name of missing parameter. – Habib Aug 25 '14 at 13:58

0 Answers0