1

这是我使用 sql 查询分析器的工作 sql 语法,它显示我想要的记录

SELECT     OE_Category, OE_ID
FROM         tblOfficeEquipmentProfile
WHERE     (OE_ID = 'dxdxdx')

在将它用于 vb.net 时:

 Public Sub DisplayCategory()
    'based on oe_id'
    Dim sqlconn As New SqlClient.SqlConnection
    sqlconn.ConnectionString = "server = SKPI-APPS1;" & _
    "Database = EOEMS;integrated security=true"

    Dim sqlcommand As New SqlCommand

    sqlconn.Open()
    Dim da As New SqlDataAdapter("SELECT OE_Category, OE_ID FROM tblOfficeEquipmentProfile WHERE OE_ID = '" & txtOEID.Text & "'", sqlconn)
    Dim dt As New DataTable
    da.Fill(dt)
    cmbCategory.DataSource = dt
    cmbCategory.ValueMember = "CAT_ID"
    cmbCategory.DisplayMember = "CAT_Name"
    sqlconn.Close()
End Sub

发生错误:

无法绑定到新的显示成员。

4

1 回答 1

5

您的选择OE_Category, OE_ID 和绑定CAT_IDCAT_Name

改为尝试:

cmbCategory.ValueMember = "OE_ID"
cmbCategory.DisplayMember = "OE_Category"

你也不绑定控件

于 2013-04-16T08:37:38.140 回答