我的上传文件代码是
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFullName As String = Me.File1.PostedFile.FileName
Dim strFileName As String = strFullName.Substring(strFullName.LastIndexOf("\") + 1)
thefile = strFileName
File1.PostedFile.SaveAs(savepath + strFileName) End Sub
导入文件代码是:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim dt As New DataTable
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + savepath + thefile + ";Extended Properties=Excel 8.0;"
Dim sql As String = "Select * from [sheet1$]"
Dim adp As New OleDb.OleDbDataAdapter(sql, strConn)
' Dim dt As New DataTable
' Try adp.Fill(dt)
....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFullName As String = Me.File1.PostedFile.FileName
Dim strFileName As String = strFullName.Substring(strFullName.LastIndexOf("\") + 1)
thefile = strFileName
File1.PostedFile.SaveAs(savepath + strFileName) End Sub
导入文件代码是:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim dt As New DataTable
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + savepath + thefile + ";Extended Properties=Excel 8.0;"
Dim sql As String = "Select * from [sheet1$]"
Dim adp As New OleDb.OleDbDataAdapter(sql, strConn)
' Dim dt As New DataTable
' Try adp.Fill(dt)
....
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货