[VBS ] LINQ to XML 的查詢
原始碼開始
Imports System.Data
Public Class custom_main
Dim xmlFile As XElement = XElement.Load("custom.xml")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click
Dim stu = From s In xmlFile.Elements() _
Where CType(s.Element("手機"), String) Like TextBox1.Text _
Select New With { _
.編號 = CType(s.Element("編號"), String), _
.姓名 = CType(s.Element("姓名"), String), _
.手機 = CType(s.Element("手機"), String), _
.生日 = CType(s.Element("生日"), String), _
.地址 = CType(s.Element("地址"), String) _
}
DataGridView1.DataSource = stu.ToList
End Sub
End Class
原始碼結束
這是小弟的查詢程式碼
執行後確定能用 紅色的地方是查詢的欄位跟查詢的關鍵字
可惜程式執行起來除非關鍵字100%吻合資料 不然什麼也查不到
請問怎麼做到我輸入093 然後所有093*的資料都會出來?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.35.210