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. unrecognized zeros in C# string format

unrecognized zeros in C# string format

Scheduled Pinned Locked Moved C#
databasetutorialcsharpmysqlhelp
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.
  • Z Offline
    Z Offline
    zoroyster
    wrote on last edited by
    #1

    Hi. I have an auto-increment database field with 5 digits. (example. "00001", "00002", "00003") But every time i query it using C#, and place it in text boxes or in labels, it always removes the zeros, so I always end up with just "1", "2", "3", etc. I'm currently using microsoft access 2003. The error also occurred when I used mySQL. Anyone know how to set form objects to recognize the zeros in the values? Thanks in advance.

    C 1 Reply Last reply
    0
    • Z zoroyster

      Hi. I have an auto-increment database field with 5 digits. (example. "00001", "00002", "00003") But every time i query it using C#, and place it in text boxes or in labels, it always removes the zeros, so I always end up with just "1", "2", "3", etc. I'm currently using microsoft access 2003. The error also occurred when I used mySQL. Anyone know how to set form objects to recognize the zeros in the values? Thanks in advance.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Its only an error if the value is a string. If it's a number at any point in the process, the 0s are meaningless, and therefore discarded. You can use string.Format to format a string to have as many zeros as it needs to fit this format.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      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