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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. spaces in SQL Server Columns (C#,VB.net)

spaces in SQL Server Columns (C#,VB.net)

Scheduled Pinned Locked Moved Database
csharpdatabasesql-serversysadmin
2 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.
  • I Offline
    I Offline
    Itanium
    wrote on last edited by
    #1

    Hello All!!!! I have got a problem, I have a generalized class for inserting/updating/and deleting data, here are few lines of code which work well for adding new records in database cmdBldr = new OleDbCommandBuilder(dataAdapter); DataRow nRow = dataTable.NewRow(); nRow.ItemArray = itemArray; dataTable.Rows.Add(nRow); dataAdapter.Update(dataTable); As command builder is used to generate the sql statements so it works well with columns names with no spaces like [FirstName], but if we make it [First Name] then it throws following exception: An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll :confused: Can anybody give me the idea that how to reslove this, i dont want to remove spaces because they coulmn names are displayed at run time on form so that if i change the name in table, it get changed on form automatically. Thanx in Advance :) sorry for my bad English.

    M 1 Reply Last reply
    0
    • I Itanium

      Hello All!!!! I have got a problem, I have a generalized class for inserting/updating/and deleting data, here are few lines of code which work well for adding new records in database cmdBldr = new OleDbCommandBuilder(dataAdapter); DataRow nRow = dataTable.NewRow(); nRow.ItemArray = itemArray; dataTable.Rows.Add(nRow); dataAdapter.Update(dataTable); As command builder is used to generate the sql statements so it works well with columns names with no spaces like [FirstName], but if we make it [First Name] then it throws following exception: An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll :confused: Can anybody give me the idea that how to reslove this, i dont want to remove spaces because they coulmn names are displayed at run time on form so that if i change the name in table, it get changed on form automatically. Thanx in Advance :) sorry for my bad English.

      M Offline
      M Offline
      mtone
      wrote on last edited by
      #2

      You should not use spaces when Naming your Database objects (tables,columns, SP, etc..) rename your columns and replace space with _ (ex. FIRST_NAME)

      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