Nel

Nel

  • NA
  • 716
  • 1.1m

InvalidArgument=Value of '0' is not valid for 'index' error

Feb 8 2012 3:23 AM
Hello,

I have two comboboxes on my windows form. When loading it, I want the second box to display only the values for which one of the fields from the database are the same as the displayed value in the first combobox.
I tried with this code:

command3.CommandText = "Select * from Komintent order by Komintent asc";
            command2.CommandText = "Select * from Dogovor where Komintent=? order by Brdog";  //I use this command to fill the second combobox

            command2.Parameters.AddWithValue("@Komintent", comboBox3.Items[0]);

and I got this error:

InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index


in the bold line above.

Could anybody please help me how to display only filtered data in the second combobox?
Thank you very much in advance.

Answers (8)