Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi sir,

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 sir?

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
Posted
Updated 26-Aug-10 19:44pm
v3
Comments
Christian Graus 27-Aug-10 1:47am    
How bizarre, you keep editing your post, but I can't see any difference in what you posted, and it doesn't change that my answer is almost certainly correct. Do you understand what I said ? Oh, you posted the code that proves my answer is correct. I see it now.

1 solution

This code does not try to update or change your file, so I don't understand your error message. However, I do notice that your data source contains the literal 'savePath', where I suspect that's a variable name that you meant to concatenate, as in (" & Server.MapPath(savePath) & ");"
 
Share this answer
 
v2

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