如何将多个数据项从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")
它仅绑定一个数据项,我想绑定特定列中的许多数据项
答案 0 :(得分:0)
您可以在SQL语句中创建一个字符串并绑定到该字符串:
Dim str1 As String = "SELECT Course_Title + '(' + Course_Code + ')' AS lbl1 FROM tbl_course"
...
lbl.DataBindings.Add("text", dataset1, "course.lbl1")