Imports System.Data.OleDb
Imports System.Data
Imports System.Diagnostics
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim m_sConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\Vikas\AutoExcel\myexcel.xls;" & _
"Extended Properties=""Excel 8.0;HDR=no"""
Dim conn2 As New OleDbConnection(m_sConn1)
Dim da As New OleDbDataAdapter("Select * From [Cities$]", conn2)
Dim ds As DataSet = New DataSet()
Dim i = 0
Dim j
da.Fill(ds)
Dim dr As DataRow
If ds.Tables(0).Rows.Count > 0 And ds.Tables(0).Rows.Count > 10 Then
For Each dr In ds.Tables(0).Rows
For j = 0 To 7
If UCase(ds.Tables(0).Rows(i).Item(j).ToString) = "TOTAL" Then
MsgBox(ds.Tables(0).Rows(i).Item(j + 1).ToString)
End If
Next
i = i + 1
Next
End If
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
conn2.Close()
End Sub
No comments:
Post a Comment