0
當我運行此代碼時,我的listbox
爲空。從SQL獲取數據並進入listbox
的最佳方式是什麼?提交表單時,我想使用CustomreID
值數據存儲到另一個表中,並認爲使用索引將是最佳解決方案。將sql數據插入到列表框中
sSQL = "SELECT CustomerID, Company from Customers Order by Company ASC"
cmd = New SqlCommand(sSQL, moConn)
rs = cmd.ExecuteReader()
While rs.Read
lsbDestination.Items.Insert(CInt(rs("CustomerID")), rs("Company"))
End While
is this webform?或winforms? – spajce
它是一個winforms – user1791536
檢查http://stackoverflow.com/a/9116889/1080742和 'lsbDestination.DisplayMember =「Company」; lsbDestination.ValueMember =「CustomerID」;' – spajce