SELECT Statement against Excel file?

How can I run sql statement against excel file. I am using office 2003 and want to run retrieve information from a column in excel file.

< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

SELECT DISTINCT Code FROM Excel_File_name Is this possible

 

Thanks  




Answer this question

SELECT Statement against Excel file?

  • mentally_disturbed

    i want to do this programmatically, using vb.net


  • tosun

    You can do this with MS Query. See Data, Import External Data, New Database Query.

    With Advanced Filter you can get unique rows as well.

  • Ver Argulla Jr.

    You need to place quotes around the extended properties in the connection string "...Extended Properties =""...""..."
  • Nicolas de Fontenay

    I tried this

    Dim conn As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
                                            "data source='" & "C:\Temp\SSPortfolio.xls" & " '; " & _
                                            "Extended Properties=Excel 8.0;" & "HDR=Yes;" & "IMEX=1")


            Dim da As New OleDbDataAdapter("SELECT * FROM [SSPortfolio$]", conn)
            Dim ds As New DataSet
            da.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)

    but getting an error message saying "Could not find installable ISAM". what thia error cud be


  • staceywilliam

    I tried this

    Dim conn As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
                                            "data source='" & "C:\Temp\SSPortfolio.xls" & " '; " & _
                                            "Extended Properties=Excel 8.0;" & "HDR=Yes;" & "IMEX=1")


            Dim da As New OleDbDataAdapter("SELECT * FROM [SSPortfolio$]", conn)
            Dim ds As New DataSet
            da.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)

    but getting an error message saying "Could not find installable ISAM". what thia error cud be


  • SELECT Statement against Excel file?