1
Reply

import excel data to datagrid?

Ask a question
ajay raju

ajay raju

14y
2.3k
1


Hi
 
A File upload area where the person can select an excel file to upload, a button to upload and then a datagrid which will display the uploaded data.
 
how to do this?

The details in this gridview are then saved to a database but before that they can be edited and some rows removed if necessary
i tried to display Excel to Datagrid but Error is occured when i Fill the data into dataset that Error message is Cannot update.  Database or object is read-only. my code is:

Dim savePath As String = "~/ExcelFiles/"
Dim fileName As String = Server.HtmlEncode(fuImportContacts.FileName)
savePath = savePath & fileName

Dim strCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=Server.MapPath(savePath);" & "Extended Properties=Excel 8.0;"

Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM [SHEET1$]", strCon)
da.TableMappings.Add("Table", "ExcelTest")
da.Fill(ds)

DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()

please give a solution
Thanks

Answers (1)