问题描述
您好,先生,
一个文件上传区域,人们可以选择一个excel文件上传,一个按钮上传,然后一个数据网格将显示上传的数据.
先生怎么办?
然后,此gridview中的详细信息将保存到数据库中,但在此之前,可以对其进行编辑,并在必要时删除一些行
我尝试将Excel显示为Datagrid,但是将数据填充到错误消息为无法更新的数据集中时,发生了错误.数据库或对象是只读的.我的代码是:
Dim savePath As String =〜/ExcelFiles/"
昏暗的FileName作为字符串= Server.HtmlEncode(fuImportContacts.FileName)
savePath = savePath& fileName
Dim strCon As String ="Provider = Microsoft.Jet.OLEDB.4.0;" & 数据源= Server.MapPath(savePath);" & 扩展属性= Excel 8.0;"
Dim ds As DataSet =新DataSet()
Dim da As OleDbDataAdapter =新的OleDbDataAdapter("SELECT * FROM [SHEET1 $]",strCon)
da.TableMappings.Add("Table","ExcelTest")
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
请提供解决方案
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
推荐答案
这篇关于将联系人从Excel导入到DataGrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!