Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. How can I define table of an existed Excel file?

How can I define table of an existed Excel file?

Scheduled Pinned Locked Moved Visual Basic
databasequestionhelpworkspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ATC
    wrote on last edited by
    #1

    I have an existed Excel file (My_Excel.xls) with pure data, when I try to open it as database ... following SQL define requires a table name (what_table?) in order to access it: conn = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & Environment.CurrentDirectory & "\My_Excel.xls; Extended Properties=Excel 8.0;" Dim SQLString As String = "SELECT * FROM what_table" DBCon = New OleDbConnection(conn) DBDat = New OleDbDataAdapter(SQLString, DBCon) DBCom = New OleDbCommandBuilder(DBDat) DatT = New DataTable DBCon.Open() DBDat.Fill(DatT) DBCon.Close() How can I define My_Excel.xls the table "what_table" in order to use the above code? :doh: Thanks to any help

    P 1 Reply Last reply
    0
    • A ATC

      I have an existed Excel file (My_Excel.xls) with pure data, when I try to open it as database ... following SQL define requires a table name (what_table?) in order to access it: conn = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & Environment.CurrentDirectory & "\My_Excel.xls; Extended Properties=Excel 8.0;" Dim SQLString As String = "SELECT * FROM what_table" DBCon = New OleDbConnection(conn) DBDat = New OleDbDataAdapter(SQLString, DBCon) DBCom = New OleDbCommandBuilder(DBDat) DatT = New DataTable DBCon.Open() DBDat.Fill(DatT) DBCon.Close() How can I define My_Excel.xls the table "what_table" in order to use the above code? :doh: Thanks to any help

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Define a named range in your spreadsheet called what_table that represents the data area you want to access.

      Paul Marfleet

      A 1 Reply Last reply
      0
      • P pmarfleet

        Define a named range in your spreadsheet called what_table that represents the data area you want to access.

        Paul Marfleet

        A Offline
        A Offline
        ATC
        wrote on last edited by
        #3

        It is working. Thanks :rolleyes:

        P 1 Reply Last reply
        0
        • A ATC

          It is working. Thanks :rolleyes:

          P Offline
          P Offline
          pmarfleet
          wrote on last edited by
          #4

          Good stuff.

          Paul Marfleet

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups