I am trying to populate combobox from access database but not geting populated

only message 1 is displayed message 2 ,3 & 4 are not displayed, nither any eror is shown

------------------------------------
Imports System.Data.OleDb

Public Class FrmPlPostCodeNl
Public acsconn As New OleDb.OleDbConnection
Public acsdr As OleDbDataReader
Public strSql As String

Private Sub FrmPlPostCodeNl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(1)
acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source = D:\Shabeeb\SSS.accdb"
acsconn.Open() '"
MsgBox(2)
strSql = "Select * from NLCODES"
Dim acscmd As New OleDb.OleDbCommand
acscmd.CommandText = strSql
acscmd.Connection = acsconn
acsdr = acscmd.ExecuteReader
While (acsdr.Read())
ComboBox1.Items.Add(acsdr("ID"))
End While
acscmd.Dispose()
acsdr.Close()
MsgBox(4)

End Sub

Try using the GetValue method and the ordinal position of the field you want from the query.
This would be "Select Field From Table" you are requesting 1 field so that's position 0

 ComboBox1.Items.Add(CStr(DataReader.GetValue(0)))

its not working

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.