Format integer with ToString("D2") in SqLite
-
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?
-
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?
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 -
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@Dave Kreskowiak, Thank you very much for answering, it helped me a lot, a hug. Where do I mark as resolved?
-
@Dave Kreskowiak, Thank you very much for answering, it helped me a lot, a hug. Where do I mark as resolved?
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!