0

I know there is a very long list of questions on the same theme but I couldn't find my answer. So I want to add a combobox column to my DataGridView. I've built in SQL a SP that returns an ID/DisplayValue. Here is the query/the result set. enter image description here

So now in VS I've built a ds with few procedures.

enter image description here

Now I've added the column with the following settings.

enter image description here

My big dataset column IDCategorie returns

enter image description here

So when I try to run this query on formLoad to see my data.

cmd = new SqlCommand("spProduse_Show", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dtProduse = new DataTable();
                sda.Fill(dtProduse);
                spProduseShowBindingSource.DataSource = dtProduse;
                dataGridView1.DataSource = spProduseShowBindingSource;
                sda.Update(dtProduse);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

and I get the error from the title, any ideas? I've done the same thing with an other column and everything works fine, but for some reason for this one it doesn't, and I can't figure it out.

Also VS added this 2 lines in form_Load event

 // TODO: This line of code loads data into the 'dsProduse.spLK_CategoriiProduse' table. You can move, or remove it, as needed.


   this.spLK_CategoriiProduseTableAdapter.Fill(this.dsProduse.spLK_CategoriiProduse);
    // TODO: This line of code loads data into the 'dsProduse.spLK_Furnizori' table. You can move, or remove it, as needed.
    this.spLK_FurnizoriTableAdapter.Fill(this.dsProduse.spLK_Furnizori);
adricadar
  • 9,971
  • 5
  • 33
  • 46
CiucaS
  • 2,010
  • 5
  • 36
  • 63

1 Answers1

0

Ok after searching a bit more, i managed to find my problem. The problem lies in with the datatype of my column. My DataPropertyName was Int16 and my ValueMember was Int32. Anyhow I've modifiend my ValueMember to Int16 and now it works. I've post this answer in case someone else gets into the same situation. Be extra carefull at the datatypes!!!

CiucaS
  • 2,010
  • 5
  • 36
  • 63