SyntaxError SyntaxError - 1 year ago 129 Question

how to fill Combobox in vb 2010 with data from database (access database)

Sorry am a beginer to Vb, therefore am looking for a simple way to fill combox with data from access database.


#connection first.

$sql = "select * from projects";
$select_records = mysqli_query($con,$sql);
while($fetch = mysqli_fetch_array($select_records)):
echo "<form>";
echo "<select name='project">";
echo "<option name='$fetch[projectname]'>$fetch[projectname]</option>";
echo "</select>";
echo "</form>";

how can i transform the above code to vbvb form with combobox

Answer Source
        Dim query as String
        Dim con as OleDbConnection
        Dim command as OleDbCommand
        Dim reader as OleDbDataReader

        query = "select * from projects"
        command = New OleDbCommand(query, con)
        reader = command.ExecuteReader()

        If reader.HasRows Then
            While reader.Read()
            End While
        End If

cb there is the combobox name. Don't forget to import OleDb at the topmost of your code like this:

imports System.Data.OleDb
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download