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. How do I insert escape sequences using SQL Compact.

How do I insert escape sequences using SQL Compact.

Scheduled Pinned Locked Moved Database
questionc++database
6 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.
  • S Offline
    S Offline
    Spawn Melmac
    wrote on last edited by
    #1

    Simple question I know but I just cannot find a anything that works.

    INSERT INTO [Location] ([id],[TZOffset],[Address],[Tel],[Fax],[Contact1],[Contact2],[Contact3],[Company],[Deleted],[Disabled]) VALUES (8,null,N'line1
    line2
    ',N'',N'',1,2,3,null,null,null);
    GO

    I have tried everything I can find but there is no ESCAPE or CHAR function in SQLCE that I can find. You cannot use Stored Procedures, being CE so it has to be done in a command space. If I store the CRLF in the raw data and push it using MFC then it works fine. Any ideas? Great isn't it. I can use SIN, COT, SQRT but I cannot put CRLF into a string!!?!??!?!

    Alan

    M 1 Reply Last reply
    0
    • S Spawn Melmac

      Simple question I know but I just cannot find a anything that works.

      INSERT INTO [Location] ([id],[TZOffset],[Address],[Tel],[Fax],[Contact1],[Contact2],[Contact3],[Company],[Deleted],[Disabled]) VALUES (8,null,N'line1
      line2
      ',N'',N'',1,2,3,null,null,null);
      GO

      I have tried everything I can find but there is no ESCAPE or CHAR function in SQLCE that I can find. You cannot use Stored Procedures, being CE so it has to be done in a command space. If I store the CRLF in the raw data and push it using MFC then it works fine. Any ideas? Great isn't it. I can use SIN, COT, SQRT but I cannot put CRLF into a string!!?!??!?!

      Alan

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Me thinks your data structure is screwed, whenever I seelsomething like contact1, contact2, contact3 I know you are in deep poop. What if there is a fourth contact, woops lets add another column - FAIL Create another table callemd contacts and a foreign key to this company table. What has CRLF got to do with your insert statement? There seems to be a number od problems with your insert statement. There is no comma between line1 and line2. Do comapny, deleted and disabled accept null as valid data.

      Never underestimate the power of human stupidity RAH

      S 1 Reply Last reply
      0
      • M Mycroft Holmes

        Me thinks your data structure is screwed, whenever I seelsomething like contact1, contact2, contact3 I know you are in deep poop. What if there is a fourth contact, woops lets add another column - FAIL Create another table callemd contacts and a foreign key to this company table. What has CRLF got to do with your insert statement? There seems to be a number od problems with your insert statement. There is no comma between line1 and line2. Do comapny, deleted and disabled accept null as valid data.

        Never underestimate the power of human stupidity RAH

        S Offline
        S Offline
        Spawn Melmac
        wrote on last edited by
        #3

        Well you would be right if that is the way the fields were being used but they are not. There will only be three contacts as these fields hold pointers to entries in a Contact table. I want to use a single ADDRESS field to store a multiline address rather than have 5 separate fields (one for each line). There is no comma between line1 & line2 becuase they are stored as "line1\r\nline2" in the application internals. Now I can do that everywhere else (CString, Registry etc...) so why is it so unreasonable to want the same thing in SQL CE?

        Alan

        M 1 Reply Last reply
        0
        • S Spawn Melmac

          Well you would be right if that is the way the fields were being used but they are not. There will only be three contacts as these fields hold pointers to entries in a Contact table. I want to use a single ADDRESS field to store a multiline address rather than have 5 separate fields (one for each line). There is no comma between line1 & line2 becuase they are stored as "line1\r\nline2" in the application internals. Now I can do that everywhere else (CString, Registry etc...) so why is it so unreasonable to want the same thing in SQL CE?

          Alan

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Not being a user of CE, and unwilling to install it in case it destabilises something, I can't test his. Have you tried forcing a linefeed manually by inserting chr(10). Then try chr(13) + chr(10), forcing a carriage return and line feed. Seems like your transport layer may be messing with the \r Thanks for the explanation (one should stick to the Lounge when one returns home pissed) but I still think field1-3 is an incorrect design.

          Never underestimate the power of human stupidity RAH

          S 1 Reply Last reply
          0
          • M Mycroft Holmes

            Not being a user of CE, and unwilling to install it in case it destabilises something, I can't test his. Have you tried forcing a linefeed manually by inserting chr(10). Then try chr(13) + chr(10), forcing a carriage return and line feed. Seems like your transport layer may be messing with the \r Thanks for the explanation (one should stick to the Lounge when one returns home pissed) but I still think field1-3 is an incorrect design.

            Never underestimate the power of human stupidity RAH

            S Offline
            S Offline
            Spawn Melmac
            wrote on last edited by
            #5

            Ok things are getting even wierder than I thought they were to start with. I have done some testing with my own code and I have observed that INSERT preserves the 0x000D,0x000A when written to the DB but then if I use UPDATE on the same field with the same data I get '?' stored in the DB?!?!?!? Now this smells to me of a bug in the OLEDB... Anway it looks like I am going to have to restructure my code and DB to provide separate fields for each address line. I then have to glue them together when I retrieve them and split them apart when writing. You are still getting hung up on the Contact1/2/3. This is simple the variable names I use within the code so I can easily find all the code dealing with the contacts. In presentation they are Primary, Secondary and Reserve. Simples. :)

            Alan

            M 1 Reply Last reply
            0
            • S Spawn Melmac

              Ok things are getting even wierder than I thought they were to start with. I have done some testing with my own code and I have observed that INSERT preserves the 0x000D,0x000A when written to the DB but then if I use UPDATE on the same field with the same data I get '?' stored in the DB?!?!?!? Now this smells to me of a bug in the OLEDB... Anway it looks like I am going to have to restructure my code and DB to provide separate fields for each address line. I then have to glue them together when I retrieve them and split them apart when writing. You are still getting hung up on the Contact1/2/3. This is simple the variable names I use within the code so I can easily find all the code dealing with the contacts. In presentation they are Primary, Secondary and Reserve. Simples. :)

              Alan

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Instead of multiple fields for the address you might look into storing it as XML data or varchar using XML to structure the address.

              Never underestimate the power of human stupidity RAH

              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