Import Excel to Gridview
Dear All,i need to import excel sheet to vb.net Gridview, and the Gridview datas have to insert into sql server.
it's happening.
But my problem is, while i import from excel to gridview, it also added some extra rows in gridview,
for example, excel contains 3 rows, while it comes to gridview it has 6 rows.
Need to remove empty rows in gridview ?
My Code is ,
Dim cn As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbDataAdapter
Dim DT As DataTable = New DataTable
cn = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & txtPath.Text & ";Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
cmd = New System.Data.OleDb.OleDbDataAdapter("select * from [Contact$]", cn)
cn.Open()
cmd.Fill(DT)
'Load the values from Data Table to Grid View
grdContactDetails.DataSource = DT
Regards,
Ramkumar G.R