use combo box to read data in SQL Server 2005 db
Posted on 2007-11-14
I could really use a lot of help on how to code a combo box in Microsoft Visual Studio if I am connected to SQL Server 2005 db.
I'm not even sure where to begin. I'm connected to the db and I can move previous and next and all of the fields on the form change the way I would expect. But I want to be able to select a FileNo from the combo box and have it fill the form with the correct data.
I have tried creating the following view in SQLServer 2005 but it won't even compile...
SELECT FileNo, SSN, FirstName, MiddleName, LastName, Dependants
WHERE (FileNo = @FileNo)
If I take off the Where clause (just to get something to work) I can save it. So I tired using the followng code in the SelectedIndexChanged property of my cboFileNo combo box. It complies but when I select a file number from the dropdown menu I get the errors
Relax or turn off constraints in your DataSets.
Clear datasets before loading them from view state.
Code in the SelectedIndexChanged property:
Private Sub LoadByFileNo(ByVal sender As System.Object, ByVal e As System.EventArgs)
I don't even know if I'm on the right track. I have viewed many "how to" videos on VB.net but none of them have an example using a dropdown menu the way I want.
I could really use some detailed help. A link to detailed instructions on how to create a combo box would also work.
Thanks in advance!