I have a combobox that I'm trying to load from an Access DB table. My connection is good and I can pull data and display it in some textboxes. I wich though to load this data into a combobox so that the use can select the required record. While the program runs, no data is displayed in the combobox. The combobox is visable, but no data is visable in the dropdown.
Would someone please show me what I'm forgetting?
Code:Imports System.Data.OleDb Public Class NewGeneralIncidentForm Dim dsIAData As New DataSet() Dim intCurrentIdx As Integer = 0 Dim da1 As New OleDbDataAdapter() Dim conn As New OleDbConnection Private Sub NewGeneralIncidentForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Data_Spill_InventoryDataSet.IA_Security_Team_Query' table. You can move, or remove it, as needed. 'Me.IA_Security_Team_QueryTableAdapter.Fill(Me.Data_Spill_InventoryDataSet.IA_Security_Team_Query) ' IA Staff Investigator Query needed. ' Location Information => Incident Location Query Form 8 conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\1078282\My Documents\Visual Studio 2008\Projects\Event Reporter\Event Reporter\Data_Spill_Inventory.mdb;User Id=admin;Password=;" da1.SelectCommand = New OleDbCommand("SELECT [SAS Employees 080929].LastName, [SAS Employees 080929].FirstName, [SAS Employees 080929].MiddleName, " _ + "[SAS Employees 080929].EmployeeID FROM [SAS Employees 080929] WHERE ((([SAS Employees 080929].DoDTeam) Is Not Null)) " _ + "ORDER BY [SAS Employees 080929].LastName, [SAS Employees 080929].FirstName") da1.SelectCommand.Connection = conn da1.Fill(dsIAData) If dsIAData.Tables(0).Rows.Count > 0 Then Label28.Text = Convert.ToString(dsIAData.Tables(0).Rows.Count) txtRoom.Text = dsIAData.Tables(0).Rows(intCurrentIdx).Item("LastName").ToString() txtAddress.Text = dsIAData.Tables(0).Rows(intCurrentIdx).Item("FirstName").ToString() txtCity.Text = dsIAData.Tables(0).Rows(intCurrentIdx).Item("MiddleName").ToString() txtState.Text = dsIAData.Tables(0).Rows(intCurrentIdx).Item("EmployeeID").ToString() cboInvestigator.BeginUpdate() 'For Each dRow As DataRow In dsIAData.Tables("SAS Employees 080929").Rows For Each dRow As DataRow In dsIAData.Tables(0).Rows cboInvestigator.Items.Add(dRow("LastName").ToString() + " ," + dRow("FirstName").ToString()) Next cboInvestigator.EndUpdate() Else MessageBox.Show("Fill Error") End If End Sub




Reply With Quote