ado.net and excel connection

V

vinodkus

HI I m trying to display record from a excel sheet in gridview. It
does not show any error but when I run my defaut.aspx page shows
blank.

i m sending the program

Protected Sub Page_Load(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim str As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("ExcelData.xls") & ";" & "Extended
Properties=Excel 8.0;"
Dim objConn As New OleDbConnection(str)
objConn.Open()
Dim objCmdSelect As New
OleDbCommand("select * from MyRange1", objConn)
Dim objAdapter1 As New OleDbDataAdapter()
objAdapter1.SelectCommand = objCmdSelect
Dim objDataSet1 As New DataSet()
objAdapter1.Fill(objDataSet1, "XLData")
GridView1.DataSource =
objDataSet1.Tables (0).DefaultView
GridView1.DataBind ()
objConn.Close()
End If
End Sub

vinod is virtual directory, website is folder inside
it and exceldata.xls is a excel file in website folder
what error can be can u tell?
if do u know plz tell me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top