Question comboBox.SelectedValue

Hrach23095

New member
Joined
Jul 15, 2016
Messages
2
Programming Experience
Beginner
I have this ... SqlCommand command = new SqlCommand("select ClientID from dbo.Client" ,con);
and this ...... string CustomerID;
HOW TO WRITE LIKE THIS >>> CustomerID=command;
 
Call ExecuteScalar on the command and it will return the first column of the first row of the result set of the query.

The thing is, your query is going to get every ClientID in the table but your CustomerID variable can only hold one of those values. That begs the question, do you want every value or just one? If it's the latter, you should have a WHERE clause in your query that filters the data down to just that one row.
 
Back
Top Bottom