Private Sub FillMCbo(ByVal theSQL As String)
Dim dr As DataRow
Dim dt As DataTable
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
pMan.Items.Clear()
sql = theSQL
Try
With da
.TableMappings.Add("Table", "Category")
cmd = New System.Data.OleDb.OleDbCommand(sql, con)
.SelectCommand = cmd
.Fill(ds)
.Dispose()
End With
ds.AcceptChanges()
dt = ds.Tables.Item(0)
ds.Dispose()
pMan.Text = ""
pMan.Items.Clear()
pMan.BeginUpdate()
For Each dr In dt.Rows
pMan.Items.Add(dr("ManName").ToString)
pMan.ValueMember = dr("ManID")
Next
pMan.EndUpdate()
pMan.SelectedIndex = 0
Catch ex As Exception
MsgBox("There was an error accessing Manufacterurs: " & vbCrLf & ex.Message, MsgBoxStyle.OkOnly, "Error!")
End Try
End Sub
|