Populating Combobox From an Oracle Database in VB.Net

Version Compatibility : Visual Basic.NET

More information : The afterward atom of cipher shows you how to abide a archetypal combobox ascendancy from an Oracle database.

Instructions : Copy the declarations and code below and paste directly into your VB project.

Declarations:

'(None)


Code:

Dim strsqla As String

strsqla = "SELECT distinct file_loc_st, to_char(rpt_dte,'mm/dd/yyyy') rptdate FROM abc_table WHERE MANUAL_IND = 'Y' and proc_ind is null "


Debug.Print(strsqla)

Dim objadap1 As Oracle.DataAccess.Client.OracleDataAdapter

objadap1 = New Oracle.DataAccess.Client.OracleDataAdapter(strsqla, objconn_orcl)



Dim m_dataset_I As DataSet

m_dataset_I = New DataSet

objadap1.Fill(m_dataset_I)

Dim tmpfund As String

cmbSearch.Items.Clear()

For Each dr As DataRow In m_dataset_I.Tables(0).Rows

tmpfund = Trim(CStr(dr("file_loc_st") & "")) & " - " & Trim(CStr(dr("rptdate") & ""))

cmbSearch.Items.Add(tmpfund)

Next

cmbSearch.SelectedIndex = 0



0 Comments: