• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

DhamenORM

  • Home
  • Download
    • Android SQLite Code Generator
    • Dhamen Code Snippet Manager
  • Getting Started
  • Video
  • Blog

How to Populate ComboBox From SQLite Database Vb.Net

June 21, 2017

Today we will learn how to populate ComboBox from SQLite database using Vb.Net.

Step 1: Create VS project.

Step 2: Add Combobox to the form.

Step 3: Create LoadCustomers function.

Visual Basic .NET
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    Private Function LoadCustomers() As DataTable
        Dim dtCustomer As New DataTable
        Dim mSQL As String = "SELECT * FROM vCustomers"
        Dim connectionString As String = "Data Source=Chinook.db;Version=3;"
 
        Try
            Using conn As New SQLiteConnection(connectionString)
                Using cmd As New SQLiteCommand(mSQL, conn)
                    conn.Open()
                    Using adapter As New SQLiteDataAdapter(cmd)
                        adapter.Fill(dtCustomer)
                    End Using
                End Using
            End Using
        Catch ex As Exception
        End Try
 
        Return dtCustomer
    End Function

Step 4: Update the following property of the combobox in the Form Load.

Visual Basic .NET
1
2
3
4
5
6
7
8
9
10
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim dt As New DataTable
 
        dt = LoadCustomers()
 
        comboCustomers.DataSource = dt
        comboCustomers.DisplayMember = "CustomerName"
        comboCustomers.ValueMember = "CustomerId"
 
    End Sub

Watch the complete tutorial

Filed Under: ADO.NET, SQLite, VB.Net

Primary Sidebar

Welcome

DhamenORM is very simple tool that will generate all the important database functions that are required by any relational database application, create, read, update, and delete (CRUD).

Recent Posts

  • Android Studio: Android beginner tutorial: Simple Spinner control using string array
  • Android Quick Tips: How to Pass Bundle to Second Activity Using Static Start Method
  • Android SQLite Data Access Objects classes generator
  • Create SQLite database programmatically using VB.NET
  • How to Populate ComboBox From SQLite Database Vb.Net

Categories

  • ADO.NET
  • Android
  • Android Spinner
  • SQLite
  • Uncategorized
  • VB.Net