8,497
社区成员
发帖
与我相关
我的任务
分享
Function SUVZHG() As DataTable
Dim fileName As String
Dim kk As New OpenFileDialog()
kk.FileName = "SUVZHG"
kk.Filter = "Excle恅璃(*.xls)|*.xls"
If kk.ShowDialog() = DialogResult.OK Then
fileName = kk.FileName
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & fileName & "';Extended Properties=Excel 8.0;"
Dim dr As New DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
Try
da.Fill(dr)
SUVZHG = dr
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End If
End Function
Function TOPRC() As DataTable
Dim fileName As String
Dim kk As New OpenFileDialog()
kk.FileName = "TOPRC"
kk.Filter = "Excle恅璃(*.xls)|*.xls"
If kk.ShowDialog() = DialogResult.OK Then
fileName = kk.FileName
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & fileName & "';Extended Properties=Excel 8.0;"
Dim dr As New DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
Try
da.Fill(dr)
TOPRC = dr
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End If
End Function
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim q = From emp In TOPRC() Group Join emc In SUVZHG() On emp("JSX") Equals emc("JSX") Into DataGroup = Group
From row In DataGroup.DefaultIfEmpty()
Select emp, Order = row
DG1.DataSource = q.CopyToDataTable
End Sub
Public Sub Linq105()
Dim categories() = {"Beverages", "Condiments", "Vegetables", "Dairy Products", "Seafood"}
Dim productList = GetProductList()
Dim query = From c In categories _
Group Join p In productList On c Equals p.Category Into Group _
From p In Group.DefaultIfEmpty() _
Select Category = c, ProductName = If(p Is Nothing, "(No products)", p.ProductName)
For Each v In query
Console.WriteLine(v.ProductName + ": " + v.Category)
Next
End Sub
http://msdn.microsoft.com/zh-cn/vstudio/bb737909#lojoin