编译后我得到一个错误
system.data.common.datarecordinternal在datalist视图中
它必须获取数据库中的数据。
Dim connectionString As String = "Data Source=11.123.123.32;Initial Catalog=RESERVATION_SYSTEM;User Id=**;Password=***"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Using con As SqlConnection = New SqlConnection(connectionString)
Dim cmd As SqlCommand = New SqlCommand("Select [Room] FROM [RESERVATION_SYSTEM].[dbo].[LMO_RESERVATION_SYSTEM_ROOM]", con)
con.Open()
Dim rdr As SqlDataReader = cmd.ExecuteReader()
roomType.DataSource = rdr
roomType.DataBind()
roomType.DataTextField = "RESERVATION_SYSTEM"
End Using
roomType.Items.Insert(0, New ListItem("--Select Room --"))
End If
字符串
1条答案
按热度按时间qcuzuvrc1#
This link帮助解决了我的问题。在databind之前,你需要包括你将在表中选择的列。
字符串