M
M
Michael2021-03-05 18:21:17
Windows Forms
Michael, 2021-03-05 18:21:17

How to upload data from combobox to database (vs windows forms)?

command.Parameters.AddWithValue("LatName", textBox2.Text);
I understand how to add data from textboxes

How to do it for comboBox, where it is selected from several parameters?
And how to check for emptiness?

This didn't work:

command.Parameters.AddWithValue("Passport", comboBox2.SelectedValue);

So too.
command.Parameters.AddWithValue("Passport", comboBox2.SelectedItem);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RealLazyCat, 2021-03-21
@RealLazyCat

1. If you have not selected any item in the comboBox, then the Selected* properties will be empty. use comboBox2.Items[0] / comboBox2.Items[1] to take the value from the list. in total in comboBox there will be comboBox2.Items.Count elements
2. check for "empty" value can be done like this comboBox2.Items[0] !=""

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question