Data Bind、DataMember 和 DataSource 不是 OleDb 的成员
DataBind, DataMember and DataSource is not a memeber of OleDb
我有一个下拉列表,其中填写了我的 oracle 数据库中所有 50 个州的缩写。
我很困惑为什么我的编码会标记以下错误:
我在另一个应用程序中使用了这个确切的编码;但是,这个标记了错误。有什么建议吗?
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
更新:对我的数据源(下拉列表的 ID)进行了更正,但它的填充方式如下:
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
错过了 html 中的 DataValueField = "column"
。
另外...DataBind、DataMember 和 DataSource 应该使用下拉列表 ID。
我有一个下拉列表,其中填写了我的 oracle 数据库中所有 50 个州的缩写。
我很困惑为什么我的编码会标记以下错误:
我在另一个应用程序中使用了这个确切的编码;但是,这个标记了错误。有什么建议吗?
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
更新:对我的数据源(下拉列表的 ID)进行了更正,但它的填充方式如下:
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
错过了 html 中的 DataValueField = "column"
。
另外...DataBind、DataMember 和 DataSource 应该使用下拉列表 ID。