将数据从MS excel导入到SQL MS访问 [英] Import data from MS excel to SQL MS access
问题描述
我想请求有关将MS Excel导入MS Access asp.net的代码。
提前谢谢。
我尝试过:
Dim xlpath As String
昏暗的用户As String = HttpContext.Current.User.Identity.Name
xlpath = Server.MapPath(〜\ excelFile \)& EXCEL_PATH.FileName
尝试
Kill(xlpath)
Catch
结束尝试
EXCEL_PATH.PostedFile.SaveAs(xlpath)
Dim strConn As String =Provider = Microsoft.ACE.OLEDB.12.0; &安培; 数据来源=& xlpath& ; &安培; Extended Properties = Excel 8.0;
Dim cnnEXCEL As OleDbConnection = New OleDbConnection(strConn)
//
我只能为此编写代码。
我想要示例代码
这是我写的一篇文章,它将Excel文件加载并解析为DataTable
然后您可以使用对象帽进入Access(或SQL Server,或其他):
https:// www.codeproject.com/Articles/1238464/CSV-Excel-File-Parser-A-Revisit
I would like to ask for the code about import MS Excel to MS Access asp.net,please.
Thank you in advance.
What I have tried:
Dim xlpath As String
Dim user As String = HttpContext.Current.User.Identity.Name
xlpath = Server.MapPath("~\ExcelFile\") & EXCEL_PATH.FileName
Try
Kill(xlpath)
Catch
End Try
EXCEL_PATH.PostedFile.SaveAs(xlpath)
Dim strConn As String = "Provider = Microsoft.ACE.OLEDB.12.0;" & "Data Source = " & xlpath & ";" & "Extended Properties = Excel 8.0 ;"
Dim cnnEXCEL As OleDbConnection = New OleDbConnection(strConn)
//
I can write code only for this. I wanted to example code
Here's an article I wrote that loads and parses an Excel file into aDataTable
object hat you can then use to put into Access (or SQL Server, or whatever):
https://www.codeproject.com/Articles/1238464/CSV-Excel-File-Parser-A-Revisit
这篇关于将数据从MS excel导入到SQL MS访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!