Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
I am importing Data from Excel I want to show progress of the data import in progress bar, I have tried but I didn't got pls give the solution

[EDIT]Text below has been moved from comment[/EDIT]
VB
Dim MyConnection As System.Data.OleDb.OleDbConnection
Try
    ''''''' Fetch Data from Excel
    '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='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")
    ' Select the data from Sheet1 of the workbook.
    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [PDFDATA$] where id is not null", MyConnection)
    MyCommand.TableMappings.Add("Table", "Attendence")
    DtSet = New System.Data.DataSet
    MyCommand.Fill(DtSet)
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    DataGrid1.DataSource = DtSet.Tables(0)
    MyConnection.Close()
    Catch ex As Exception
    MyConnection.Close()
End Try
Posted
Updated 29-Nov-11 6:38am
v2
Comments
Manoj K Bhoir 28-Nov-11 12:03pm    
Please provide some code snipets which will help us to understand how you are importing data from excel.
eswar_kanchu 29-Nov-11 8:10am    
Dim MyConnection As System.Data.OleDb.OleDbConnection

Try

''''''' Fetch Data from Excel

'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='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")

' Select the data from Sheet1 of the workbook.

MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [PDFDATA$] where id is not null", MyConnection)

MyCommand.TableMappings.Add("Table", "Attendence")
DtSet = New System.Data.DataSet

MyCommand.Fill(DtSet)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
DataGrid1.DataSource = DtSet.Tables(0)
MyConnection.Close()

Catch ex As Exception
MyConnection.Close()
End Try

Mr Manoj I am sending Excel Code
Maciej Los 29-Nov-11 12:42pm    
Please, always use "Improve question" link and don't select "Treat my content as plain text, not as HTML".

1 solution

In your code snippet, you're not importing row-by-row yourself. You're selecting the entirety of the Excel sheet, which doesn't report progress. What you want isn't possible with the code you're using, and frankly, changing the code to do so would only slow it down as you'd have to parse each row yourself to satisfy the WHERE clause.
 
Share this answer
 
Comments
eswar_kanchu 10-Dec-11 11:11am    
Thank u for ur reply
pls tell me, how could I get data row by row from excel to .net 2005 datagrid view

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900