Skip to content

Dropdownlist data selection

gagan

Asked Jun 26, 2006, 1:57 PM EDT1 answer
Share
LinkedInX
Hello, I have two databases db1 and db2. Database db1 has table tbl1 containing fields empcode1 and salary. Database db2 has table tbl2 containing fields empcode2 and empname. I am showing empname from the tbl2 of database db2 in the dropdownlist-ddl1. On clicking submit button I want to display salary of all those employees whose empcode1 matches with empcode2 in the 2 tables of db1 and db2. So the empname in tbl2 should get converted into empcode2 internally & then match itself with corresponding empcode1 in table tbl1 How to handle the dropdownlist ddl1 for empname,empcode1 & empcode2? empcode, empcode1, empcode2 are of type varchar. Regards and Thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    ‘I created a class of my own with properties and assigned them in the loop or for/next statement below. I added them to a listbox as ‘they were created. 'pre configured dataAdapter(sql written during dataAdapter creation) fill method executed intRecordCount = daAdapter.Fill(dsCustomers) For intX = 0 To (intRecordCount - 1) intAccountID = dsCustomers.Tables(0).Rows(intX).Item("pkAccountID") strFamilyName = dsCustomers.Tables(0).Rows(intX).Item("fldFamilyName") strFirstName = dsCustomers.Tables(0).Rows(intX).Item("fldFirstName") strPCode = dsCustomers.Tables(0).Rows(intX).Item("fldPCode") ' Account holder objects created ListBox1.Items.Add(New CAccount(intAccountID, strFamilyName, strFirstName, strPCode)) Next Then I used the SelectedItem property of the ListBox so that I could query the second database table according to ‘WHO’ was selected in the ListBox. Dim dsTransActionData As New DataSet 'get the AccountID of selected list box member intAccountID = ListBox1.SelectedItem.AccountID 'use the selected AccountID as an argument for the sql command daTransAdapter.SelectCommand.Parameters("fkAccountID").Value = intAccountID intCountRec = daTransAdapter.Fill(dsTransActionData) For intX = 0 To (intCountRec - 1) decAmount = dsTransActionData.Tables(0).Rows(intX).Item("fldAmount") If decAmount > 0 Then decCredit += decAmount Else decDebit += decAmount End If Next
    0