I'm querying a db and I want to load in data into a ComboBox. Has anyone played around with this? It has to be real easy and similiar to throwing data into a DataGrid? My code is below.....
MY CODE:
Code:Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dsV As DataSet dsV = LoadVendors() cboVendors.DataSource = dsV.Tables("VENDORS") End Sub Public Function LoadVendors() As DataSet Dim cnNODsql As New SqlConnection("server=serv;database=NOLCsql;uid=sa;pwd=;") Dim cmdSelect As New SqlCommand() Dim daVendors As New SqlDataAdapter() Dim dsVendors As New DataSet() Try With cmdSelect .CommandText = "spLoadVendors" '"spSELECTUnassignedOrders" SearchTitlesByAuthorLastName" .CommandType = System.Data.CommandType.StoredProcedure .Connection = cnNODsql End With With daVendors .SelectCommand = cmdSelect .Fill(dsVendors, "VENDORS") End With LoadVendors = dsVendors Catch excSQL As SqlException ' Add exception handling End Try End Function
thanks again.....


Reply With Quote
Bookmarks