Using this code, the display member of the combo box is displaying the text "System.Data.Da taViewManagerLi stItemTypeDescr iptor". Huh???
The first block of code gets the data from the database, and works as far as I know. The second block of code sets the first value of the form, and does NOT work like I want it too. I commented out the line that sets the value member, because it gives an exception.
The first block of code gets the data from the database, and works as far as I know. The second block of code sets the first value of the form, and does NOT work like I want it too. I commented out the line that sets the value member, because it gives an exception.
Code:
Public Function FillFromAccess(ByVal QueryString As String, ByVal FillTable As String)
Dim OLEConnString As String
OLEConnString = "Provider=" & My.Settings.Connection_AccessProvider & ";" _
& "Data Source=" & My.Settings.Connection_Location & ";" ' _
' & "Initial Catalog=Blah;" _
' & "User Id=username;" _
' & "Password='password';"
Dim DBConn As New OleDbConnection(OLEConnString)
Dim DBCommand As OleDbDataAdapter
Dim DataSetAccess As New DataSet
' For any data needed, pull it out of the database.
DBCommand = New OleDb.OleDbDataAdapter(QueryString, DBConn)
' Once that's ready, use it to fill the dataset DSPageData:
DBCommand.Fill(DataSetAccess, FillTable)
FillFromAccess = DataSetAccess
End Function
Code:
Private Sub Add_action_items_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Load the job number into the job number combo box
Dim SQL As String
Dim DataSet_Jobs_Incomplete As New DataSet
'Find the information from the database
SQL = "Select * From Jobs WHERE Completed <> True"
DataSet_Jobs_Incomplete = FillFromAccess(SQL, "Jobs_Incomplete")
'Add the list of job numbers to the combo box
With CmbJobNum
.DataSource = DataSet_Jobs_Incomplete
'.ValueMember = "ID"
.DisplayMember = "Job_num"
.SelectedIndex = 0
End With
End Sub
Comment