i'm new to VB.Net programming but i want help. i have two MySQL tables created using the following SQL statements:

create table tbldepartments (
    departmentID TINYINT( 2 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    department VARCHAR( 25 ) NOT NULL UNIQUE
) AUTO_INCREMENT = 50;

create table tblemployees (
    employeeID INT( 6 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    deptID TINYINT( 2 ) UNSIGNED NOT NULL,
    firstName VARCHAR( 20 ) NOT NULL,
    lastName VARCHAR( 20 ) NOT NULL,
    salary DOUBLE( 6,2 ) UNSIGNED NOT NULL,
    dateHired DATE NOT NULL,
    dateCreated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY ( deptID ) REFERENCES tbldepartments ( departmentID )
) AUTO_INCREMENT = 305851;

i have created a form in VB.Net for adding new employees. on that form there is a combo box from which the user selects the new employee's department. i want the combo box to be loaded with all the rows in the tbldepartments table when the form loads. how do i do this in VB.Net?

               Dim strSQL As String = "SELECT distinct deptid,deptname FROM tablename"
               Dim da As New OleDbDataAdapter(strSQL, Connection)
               Dim ds As New DataSet
               da.Fill(ds, "tablename")
               With combobox1
                    .DataSource = ds.Tables("tablename")
                    .DisplayMember = "deptname"
                    .ValueMember = "deptid"
               End With
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.