Imports System.Data.Odbc
Imports System.Data
Public Class Form2
Dim conn As OdbcConnection
Dim strcon As String
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As OdbcConnection = New OdbcConnection()
Dim da As OdbcDataAdapter
Dim ds As DataSet = New DataSet
Dim strcon As String = "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO;Excel 8.0;ReadOnly=0; DBQ=D:\\nicha\\Model.xls"
conn = New OdbcConnection(strcon)
conn.Open()
Dim strSQL As String
strSQL = "SELECT [Sheet2$].Customer,Group,[Sheet2$].Assembly,sum(M1),sum(M2),sum(M3) FROM [Sheet1$],[Sheet2$] where [Sheet2$].Assembly = [Sheet1$].Assembly Group by [Sheet2$].Customer,Group,[Sheet2$].Assembly "
da = New OdbcDataAdapter(strSQL, conn)
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
conn.Close()
da = New OdbcDataAdapter(strSQL, conn)
da.Fill(ds)
End Sub
End Class