0

如何将 SQL 中的多个数据项绑定到标签?

这是我的代码:

    Dim str As String = ("Data Source=PC1; User ID=sa; Password=pwd;Databasfriend")
    Dim con As New SqlConnection(str)
    Dim str1 As String = "SELECT * FROM tbl_course"
    Dim da As New SqlDataAdapter(str1, con)
    Dim dataset1 As New DataSet()
    da.Fill(dataset1, "course")
    lbl.DataBindings.Add("text", dataset1, "course.Course_Code")

它只绑定一项数据,我想在特定列中绑定多项数据

4

1 回答 1

0

您可以在 SQL 语句中创建一个字符串并绑定到该字符串:

Dim str1 As String = "SELECT Course_Title + '(' + Course_Code + ')' AS lbl1 FROM tbl_course"

..

lbl.DataBindings.Add("text", dataset1, "course.lbl1")
于 2013-03-26T18:45:04.573 回答