Hi,
I have a combobox and the value selected I want to use as a parameter. The field is of type Number in the access database, but when using the parameter for inserting the value in the database I get an error:
Unable to cast object of type 'System.Data.DataRowView' to type 'System.IConvertible'. and the code is:
int garbr = Convert.ToInt32(comboBox1.SelectedItem);
com.Parameters.AddWithValue("@Garbr", garbr);
if I write the code like:
com.Parameters.AddWithValue("@Garbr", comboBox1.SelectedItem);
I get an error:
"Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."
in : com.ExecuteNonQuery();
and the comboBox1.SelectedItem doesn't get a value, unlike the other parameters for which I also use combobox values, but of type text (they have the correct value when debugging)
Can anybody help me please?
Thanks
Loading
VulpesPosted Feb 21, 2012, 9:07 AM
I'd try:
if (comboBox1.SelectedIndex > -1)
{
}
Sudarshan RathodPosted Aug 22, 2016, 6:53 AM
NelPosted Feb 23, 2012, 7:49 AM
Can you please help me how it would be the opposit situation?
I have a combobox and when clicking on a datagridview row I retrieve the values of the row in the combobox, datatimepicker.... But the combobox.selecteditem doesn't return the correct value. Again because of the DataGridView type.
I have
comboBox1.SelectedItem =
Convert.ToInt32(dataGridView2.SelectedRows[0].Cells[0].Value);
but it is not changing when clicking on different rows in the datagridview.
Can you please help me?
I will post this as a new post now.
Thanks in advance
NelPosted Feb 22, 2012, 3:16 AM