On web from, how to get absolute path after user select an local excel file ?

Kerry Ou 226 Reputation points
2021-05-19T03:18:09.193+00:00

Hi all,
I want to import excel file to SQL on web from, how can I get the absolute path after user select this file?
I want to get the Excel local absolute path put into textbox1 then change the data source

Dim fileName = textbox1.Text

like:
Dim strConn As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Admin\Desktop\Basic Data.xlsx;Extended Properties='Excel 12.0;HDR=YES'"

change:
Dim strConn As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=" & fileName & " ;Extended Properties='Excel 12.0;HDR=YES'"

 Protected Sub Bt_Ex_Click(ByVal sender As Object, ByVal e As EventArgs)

        Try
            Dim fileName = textbox1.Text
            Dim strConn As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Admin\Desktop\Basic Data.xlsx;Extended Properties='Excel 12.0;HDR=YES'"

            Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)

            Dim ds As DataSet = New DataSet

            da.Fill(ds, "dw")

Thank you for your help.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,139 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,564 questions
{count} votes