Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2005
    Location
    Wake Forest, NC
    Posts
    4

    Question Unanswered: SQLCE syntax for multiple word columns

    What is the syntax when creating a SQL statement and using a column that has a multiple word name?

    I know that in query analyzer it should be delimited? by double quotation marks like such:
    SELECT Item, "Item Description" FROM ComponentList WHERE Item = 'CPU'
    The above works great in Query Analyzer on the device and in the device emulator.

    but I'm attempting to build a SQL string in code...VB.Net using CF and PocketPC SDK, SQLCE on the PocketPC device....

    Here's the snippet that does not work:
    sql = "SELECT Item, 'Item Description' FROM ComponentList WHERE Item = '" & selectedItem & "' "

    Try
    cnITSComponents.Open()
    cmdItems = New SqlCeCommand(sql, cnITSComponents)
    drItems = cmdItems.ExecuteReader()
    fieldCount = drItems.FieldCount

    While drItems.Read()
    .....More code here not copied

    I'm trying to fill a listview control and when I use the above syntax one of the columns is filled with the text Item Description instead of pulling the actual Item Description from the table...So what is the correct way to construct the SQL string?

    Thanks
    Greg

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    SELECT Item, [Item Description] FROM ComponentList WHERE Item = 'CPU'
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Feb 2005
    Location
    Wake Forest, NC
    Posts
    4
    Thras,
    Thanks for the quick reply but I had tried that earlier...uhmmm forgot to mention it too.... but that syntax throws an exception...Minor Err 25501..."There was an error parsing the query"...Err. Par.: [

    Greg

  4. #4
    Join Date
    Feb 2005
    Location
    Wake Forest, NC
    Posts
    4
    I figured it out. Surround the multiple word column with two double quotes as such:
    sql = "SELECT Item, ""Item Description"" FROM ComponentList WHERE Item = '" & selectedItem & "' "

    Thanks for the reads and Thras thanks again for the reply

    Greg

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    "...to the pain"

    Can't you change the column names? Or is it too far along.

    If it is...go yell at the DBA...

    Even though Objects can have spaces, they should be eliminated...
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  6. #6
    Join Date
    Feb 2005
    Location
    Wake Forest, NC
    Posts
    4
    I'm in the early stages of converting a "legacy" Access app to SQL Server and I most probably will convert the multiple word objects to single word objects when I get a little further along. Right now the users are still actively updating the Access db so I wanted to wait until we got a little closer to done and then maybe even script something to do it

    I would yell at the DBA....if there was one!

    Greg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •