Search code examples
vb.netoracle10gdropdownboxoledbcommand

DataBind, DataMember and DataSource is not a memeber of OleDb


I have a dropdown list that fills in with the abbreviation of all 50 states from my oracle database.

I am confused why my coding is flagging the following errors:

enter image description here

I have used this exact coding in another application; however, this one flags the error. Any suggestions?

Imports System
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports System.Text
Imports System.Security.Principal

Public Class SuppUpdate
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
        If Not States Is Nothing Then

            Dim conn As OleDbConnection = New OleDbConnection("Provider=""*****"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)

            Dim SupplierState As OleDbCommand = New OleDbCommand("SELECT column_name FROM table_name order by column_name", conn)
            Dim OracleDataAdapterAds1 As OleDbDataAdapter = New OleDbDataAdapter
            OracleDataAdapterAds1.SelectCommand = SupplierState
            Dim DsAds As DataSet = New DataSet
            DsAds.Clear()
            conn.Open()
            If Not (DsAds Is Nothing) Then
                OracleDataAdapterAds1.Fill(DsAds, "table_name")
                SupplierState.DataSource = DsAds
                SupplierState.DataMember = "table_name"
                SupplierState.DataBind()
            End If

        End If
        End If
End Sub

UPDATE: made the correction to my DataSource (id of dropdown list) but it fills like so:

enter image description here

If Not StatesList Is Nothing Then

            Dim conn As OleDbConnection = New OleDbConnection("Provider=""****"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)

            Dim SupplierState As OleDbCommand = New OleDbCommand("SELECT column FROM table order by column", conn)
            Dim OracleDataAdapterAds1 As OleDbDataAdapter = New OleDbDataAdapter
            OracleDataAdapterAds1.SelectCommand = SupplierState
            Dim DsAds As DataSet = New DataSet
            DsAds.Clear()

            If Not (DsAds Is Nothing) Then
                OracleDataAdapterAds1.Fill(DsAds, "table")
                StatesList.DataSource = DsAds
                StatesList.DataMember = "table"
                StatesList.DataBind()
            End If
 End if

Solution

  • Missed the DataValueField = "column" in the html.

    Plus... the DataBind, DataMember and DataSource should use dropdownlist ID.