C# Displaying A Sql Database Object's Name In A Label.text Property On "selectedindexchanged" Event
I am trying to make a small contact book that takes contacts details from a mssql database.It has 3 tables: contacts, last_talk(last time i talked with a contact+short description
Solution 1:
That's because in your PopulateContactLabels method, you are selecting the whole Contact table and then reading through the whole list, so it's always the last one which is shown.
You need a query more like SELECT * FROM Contact WHERE ContactId = @contactID, and then add the contactId (or whatever value you are using to find the contact) as a parameter on the SqlCommand object.
Post a Comment for "C# Displaying A Sql Database Object's Name In A Label.text Property On "selectedindexchanged" Event"