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. General Programming
  3. C#
  4. Format integer with ToString("D2") in SqLite

Format integer with ToString("D2") in SqLite

Scheduled Pinned Locked Moved C#
databasesql-serversqlitesysadminquestion
4 Posts 3 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
    Edilson Lemos 2021
    wrote on last edited by
    #1

    I'm trying to save my list of numbers with a Zero to the left of the numbers <=9 and it's not having any effect, I'm using the following code in Insert:

    cmd.Parameters.AddWithValue("@_01", número._01.ToString("D2"));

    I have the same code on Sql server and it works perfect, would there be another way to do this in SqLite?

    D 1 Reply Last reply
    0
    • E Edilson Lemos 2021

      I'm trying to save my list of numbers with a Zero to the left of the numbers <=9 and it's not having any effect, I'm using the following code in Insert:

      cmd.Parameters.AddWithValue("@_01", número._01.ToString("D2"));

      I have the same code on Sql server and it works perfect, would there be another way to do this in SqLite?

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

      Displaying leading zeros on a number is usually a UI presentation thing, not a database thing. Is the SqlLite column a numeric one or is it a text column? If you're not actually verifying this right now, after you read this, you're guessing and that's bad for troubleshooting. Leading zeros on a value will only work if the column type is NOT numeric. Like I said, this is usually something that should be handled by the UI, not in the database.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Displaying leading zeros on a number is usually a UI presentation thing, not a database thing. Is the SqlLite column a numeric one or is it a text column? If you're not actually verifying this right now, after you read this, you're guessing and that's bad for troubleshooting. Leading zeros on a value will only work if the column type is NOT numeric. Like I said, this is usually something that should be handled by the UI, not in the database.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        E Offline
        E Offline
        Edilson Lemos 2021
        wrote on last edited by
        #3

        @Dave Kreskowiak, Thank you very much for answering, it helped me a lot, a hug. Where do I mark as resolved?

        OriginalGriffO 1 Reply Last reply
        0
        • E Edilson Lemos 2021

          @Dave Kreskowiak, Thank you very much for answering, it helped me a lot, a hug. Where do I mark as resolved?

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          You don't have to - forums here don't have a facility for that as they are discussion based rather than "Question / Answer". We have an area for those that has a "solved" indicator: Quick Answers[^]

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          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