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. Can we search column in MS access (or in Excel) table with the header which contains spaces? [modified]

Can we search column in MS access (or in Excel) table with the header which contains spaces? [modified]

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestionannouncement
3 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 am able to use SQL commands to access any table & any columns in MS access (or in Excel) table. However, when I try to search columns with spaces (ie: Employee IDNumber, Employee Name, ...) then I have errors If I change to Employee_IDNumber, Employee_Name then it is OK Dim m_sModification As String = "UPDATE [Table Name$] SET Employee_Name = 'Jonny White' WHERE Employee_IDNumber = '12345678'" Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConnection1) conn1.Open() But I have the MS Access (or Excel) tables having Column Headers with spaces between, I try to avoid changing all of them with xxxxx**_**xxxxx Do we have other ways to deal with this issue? Thank in-advanced :doh:

    modified on Thursday, April 3, 2008 10:34 AM

    D 1 Reply Last reply
    0
    • A ATC

      I am able to use SQL commands to access any table & any columns in MS access (or in Excel) table. However, when I try to search columns with spaces (ie: Employee IDNumber, Employee Name, ...) then I have errors If I change to Employee_IDNumber, Employee_Name then it is OK Dim m_sModification As String = "UPDATE [Table Name$] SET Employee_Name = 'Jonny White' WHERE Employee_IDNumber = '12345678'" Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConnection1) conn1.Open() But I have the MS Access (or Excel) tables having Column Headers with spaces between, I try to avoid changing all of them with xxxxx**_**xxxxx Do we have other ways to deal with this issue? Thank in-advanced :doh:

      modified on Thursday, April 3, 2008 10:34 AM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You have to enclose and table names and columns with spaces, or names with the potential to have spaces, in square brackets ([]). Like this:

      UPDATE [Table Name$] SET [Employee Name] = 'Jonny White' WHERE [Employee IDNumber] = '12345678'

      But, keep in mind that having spaces in table and column names is considered bad practice. Avoid doing this if at all possible.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      A 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You have to enclose and table names and columns with spaces, or names with the potential to have spaces, in square brackets ([]). Like this:

        UPDATE [Table Name$] SET [Employee Name] = 'Jonny White' WHERE [Employee IDNumber] = '12345678'

        But, keep in mind that having spaces in table and column names is considered bad practice. Avoid doing this if at all possible.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

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

        Hi Dave, It works! I am awared of your comments, however the existed files that has columns with spaces being done long time ago & I am not allow to remove spaces Many thanks :-D

        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