Get Databack from combobox.
-
Hi ALl. I populated combobox from DB. And now when user select the value, how can i get the ID back.Because the selectedindex id diffirent from the original ID. Thanks.
Depending on what type of application you're developing, the
SelectedValue
should give you either the selected database ID, or aDataRowView
containing the values loaded from the database. If it doesn't, then you've not set up the binding correctly. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Hi ALl. I populated combobox from DB. And now when user select the value, how can i get the ID back.Because the selectedindex id diffirent from the original ID. Thanks.
I just use comboboxname.text. It will be a text file. If you want to get something from the DB, forget the index and just use a sql statement "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"
-
I just use comboboxname.text. It will be a text file. If you want to get something from the DB, forget the index and just use a sql statement "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"
Use Value instead. Getting the ID from a table with millions of records is much quicker by ID than it is by searching for a string.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
I just use comboboxname.text. It will be a text file. If you want to get something from the DB, forget the index and just use a sql statement "SELECT * FROM db WHERE value = '" & comboboxname.text & "'"
Member 8345599 wrote:
"SELECT * FROM db WHERE value = '" & comboboxname.text & "'"
Looks like you've got some reading to do! Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^] How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^] Query Parameterization Cheat Sheet | OWASP[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer