我有一个下拉列表,填写了我的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
更新:对我的DataSource(下拉列表的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
答案 0 :(得分:0)
错过了html中的DataValueField = "column"
。
Plus ... DataBind,DataMember和DataSource应使用下拉列表ID。