Dim conn As New System.Data.OleDb.OleDbConnection()
        conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"

        If conn.State = ConnectionState.Open Then conn.Close()
        conn.Open()

        Dim sql As String = "SHOW * From tbl_info Where AdminNo = '" & ListBoxassign.Items & "'"

        listboxassign.items.show(AdminNo)

There is no "Show" keyword in SQL Statement to retrieve data from a table.
Your SQL Statement swhould be

Dim sql As String = "Select * From tbl_info"

Now create a command object and dataReader object to read data from that table.

have error

Dim sql As String = "Select * From tbl_info = '" & ListBoxassign.Items & "'"

(Error 1 Operator '&' is not defined for types 'String' and 'System.Windows.Forms.ListBox.ObjectCollection'. )

i waned to show the adminno on the listbox

Private Sub ListBoxassign_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxassign.SelectedIndexChanged

    Dim conn As New System.Data.OleDb.OleDbConnection()
    conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"

    If conn.State = ConnectionState.Open Then conn.Close()
    conn.Open()

    Dim sql As String = "Select * From tbl_info where AdminNo"

    Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
    sqlCom.Connection = conn

    Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader

    While sqlReader.Read = True

        **ListBoxassign = (sqlReader.Item("AdminNo").ToString)**



    End While
    sqlReader.Close()
    sqlCom.Dispose()
    conn.Close()

like this.. i have change but
ListBoxassign = (sqlReader.Item("AdminNo").ToString)

error how to write it

ListBoxassign = (sqlReader.Item("AdminNo").ToString)

It should be

ListBoxassign.Items.Add(sqlReader.Item("AdminNo").ToString)
This article has been dead for over six months. Start a new discussion instead.