0

好的,所以我可以毫无问题地从我的数据库中加载我的 ComboBoxes 并为其分配正确的 ValueMember,但我需要连接“user_last_name”和“、”和“user_first_name”,以便它显示比用户名更好的信息。希望这只是一个简单的修复,我

Private Sub loadMemberName()

    Dim memberSELECTSQLString As String =
        "SELECT * FROM user_tbl"
    Dim da As New OleDbDataAdapter(memberSELECTSQLString, conn)
    Dim ds As New DataSet

    da.Fill(ds, "user_tbl")

    With memberComboBox
        .DataSource = ds.Tables("user_tbl")
        .DisplayMember = "user_username"
        .ValueMember = "user_id"
        .SelectedValue = -1
    End With
End Sub

任何帮助将不胜感激!

4

4 回答 4

1
SELECT CONCAT(user_last_name, ', ', user_first_name) username FROM user_tbl

或者

SELECT CONCAT(user_last_name, ', ', user_first_name) AS username FROM user_tbl
于 2012-10-24T14:59:20.107 回答
0

在你的 sql 中连接它并发回别名,然后在你的组合框中引用别名

于 2012-10-24T14:32:49.483 回答
0

如果您不知道连接的语法

select top 10 [docID] + ' ' + [textHash] as [userName], [docID] from docSVsys 
于 2012-10-24T14:45:04.723 回答
0
Private Sub loadMemberName()

    Dim memberSELECTSQLString As String =
        "SELECT user_id, user_last_name + ', ' + user_first_name AS username FROM user_tbl"
    Dim da As New OleDbDataAdapter(memberSELECTSQLString, conn)
    Dim ds As New DataSet

    da.Fill(ds, "user_tbl")

    With memberComboBox
        .DataSource = ds.Tables("user_tbl")
        .DisplayMember = "username"
        .ValueMember = "user_id"
        .SelectedValue = -1
    End With
End Sub
于 2012-11-08T15:55:48.663 回答