作者purpleinlove (小冰)
看板Visual_Basic
标题[VBS ] LINQ to XML 的查询
时间Fri Aug 21 04:30:31 2009
原始码开始
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