TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sathya Narayan
NA
155
65k
Error: external table is not in the expected format
Dec 27 2013 5:28 AM
Hi,
I am getting an error when fetching the excel sheet to datagridview.This is the error i am getting external table is not in the expected format in vb.net.So any one find where exactly the error.The values values are not Binding to dataset.
This is my code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim openbox As New OpenFileDialog
openbox.Filter = "Excel Workbook (*.xls) |*.xls;*.xlsx"
openbox.ShowDialog()
Dim fname As String = openbox.FileName
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection _
("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & fname & "; Extended Properties=Excel 8.0")
MyCommand = New System.Data.OleDb.OleDbDataAdapter _
("select * from [Sheet1$]", MyConnection)
Dim workbook As DataSet = New DataSet()
MyCommand.TableMappings.Add("Table", "testtable")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet, "testtable")
DataGridView1.DataSource = DtSet.Tables(0)
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Thanks & Regards,
sathya
Reply
Answers (
4
)
How to convert arabic aspx content to pdf document?
how to split decimal values in c#