0
.hi大家對我有這樣的代碼:如何改變基於DataReader的結果VB文本框的選擇選項
Private Sub EditPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'InventorySysDataSet.tb_master_products' table. You can move, or remove it, as needed.
Me.Tb_master_productsTableAdapter.Fill(Me.InventorySysDataSet.tb_master_products)
sqlCnn = New SqlConnection("Data Source=ZEREY\SQLEXPRESS2008;Initial Catalog=InventorySys;Integrated Security=SSPI")
Me.txtRowId.Text = Form1.txtRowId.Text
'MsgBox(Me.txtRowId.Text)
sql = "Select * from tb_master_inventory_per_day where Inventory_Date = " & txtRowId.Text & ""
Dim upcmd As New SqlCommand("Select * from tb_master_inventory_per_day where Row_Id = @Row_Id", sqlCnn)
upcmd.Parameters.Add(New SqlParameter("@Row_Id", Me.txtRowId.Text))
upcmd.Connection.Open()
Try
Dim dr As SqlDataReader = upcmd.ExecuteReader()
If dr.Read Then
txtInventoryDate.Text = dr.Item("Inventory_Date")
cboProductCode.DisplayMember = dr.Item("Product_Code")
txtQty.Text = dr.Item("Product_Count")
Else
MessageBox.Show("Error!")
End If
Catch ex As SqlException
If ex.Number <> 0 Then
'ErrorProvider1.SetError(Me.txtuseridprofile, "Login Id: " &
'Me.txtuseridprofile.Text & " :Not Found!")
upcmd.Connection.Close()
Exit Sub
End If
End Try
upcmd.Connection.Close()
End Sub
我想要做的是自動改變cboProductCode的選擇的選項在頁面加載取決於執行onload的查詢的結果也是。 請幫助! TIA!
我們在說客戶端還是服務器端?也許你可以發表那些有查詢的代碼段,並告訴我們你想在哪裏或什麼時候更新DropDownList(它是我們正在談論的DropDownList,不是嗎?)。 – jhsowter 2012-02-06 22:59:49
。它是一個下拉列表。 – zerey 2012-02-06 23:00:50