1
Answer

using combobox.selectedvalue in a query

Hello everybody,
I'm just starting to discover C#.
I have a form with a combobox.
This combobox is filled from a database like this :
combobox .SelectedIndex = -1;
combobox .SelectedValue = -1;
combobox .DataSource = sqlDataHelper.DataSet.Tables[0];
combobox .ValueMember = "ShipyardID";
combobox .DisplayMember = "ShipyardName";

When the user makes a choice, this will happen :

object m_shipyardID = combobox .SelectedValue;

Because my Value is an int.
I tried "string m_shipyardID = combobox .SelectedValue;" but that doesn't work.

Now I want to use the m_shipyardID in a query like this :
SELECT * FROM Shipyards WHERE shipyardID = m_shipyardID

But this doesn't work.
Please can somebody help me?
Thanks,
Tania
Answers (1)