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. Simple SQL format question

Simple SQL format question

Scheduled Pinned Locked Moved Database
questiondatabasehelp
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.
  • E Offline
    E Offline
    Enochs
    wrote on last edited by
    #1

    I am having problems with the following SQL command: SELECT * FROM Classes ---Works like a charm SELECT * FROM Classes WHERE Class_Number = 2222 ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting the nvarchar value '11-1111' to data type int. ---I can understand that. Without quotes, sql thinks the Class_Number column is of type int (its actually nvarchar). So let me add quotes... _______________________________ SELECT * FROM Classes WHERE Class_Number = "2222" ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Invalid column name '2222'. Now that error has me stumped!!! What am I missing here?:mad:

    D 1 Reply Last reply
    0
    • E Enochs

      I am having problems with the following SQL command: SELECT * FROM Classes ---Works like a charm SELECT * FROM Classes WHERE Class_Number = 2222 ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting the nvarchar value '11-1111' to data type int. ---I can understand that. Without quotes, sql thinks the Class_Number column is of type int (its actually nvarchar). So let me add quotes... _______________________________ SELECT * FROM Classes WHERE Class_Number = "2222" ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Invalid column name '2222'. Now that error has me stumped!!! What am I missing here?:mad:

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Use single quote '2222' david

      E 1 Reply Last reply
      0
      • D David Mujica

        Use single quote '2222' david

        E Offline
        E Offline
        Enochs
        wrote on last edited by
        #3

        Thanks, that worked. Kind of funny how simple that was. In the time it took to get a response, I wrote a complicated Regular Expression Validator control to get around the issue..... Let me go delete that. lol

        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