Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:54:45+00:00 2026-06-05T04:54:45+00:00

scenario: I have a database having a record 001234 and I am calling it

  • 0

scenario:
I have a database having a record 001234 and I am calling it with cmd.executescaler(); into a int variable. The problem is when I retrieve the saved data (001234) data from that variable it gives only 1234. 00 in 001234 are important, this was the problem first coming in db where sql omits the first zero’s then I changed the datatype to nvarchar which works, how I can retrieve the data on the form exactly 001234.

Note: I cannot take the data into string as I have to also apply some calculations on them.

using Sql Server visual studio 2010 c#

Hope it is clear not vague. If you need more information tell me.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:54:47+00:00Added an answer on June 5, 2026 at 4:54 am

    If those leading zeros have some meaning and can’t be left out, conversion can be done:

                int number = 0;
                string strNumber = (string)cmd.ExecuteScalar();
                if(int.TryParse(strNumber, out number))
                {
                    // process number
    
                    // if you want some output to be formatted with leading 
                    // zeros you can use PadLeft method
                    int totalNumberOfDigits = 6;
                    string strResult = number.ToString().PadLeft(totalNumberOfDigits, '0');
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The scenario is that i have a bulky database of around 500,000 records having
Our scenario: We have a main database that stores company-wide information. We have several
I have a typical dev scenario: I have a SQL 2008 database that I
I have the following scenario: I have various user's data stored in my database.
Database: DB2 v9.5 on AIX Scenario: I have 2 instances- db2inst1 and db2inst2. I
I think my scenario is pretty common. I have a database and I want
I have the following scenario: Entities are loaded from the database. One of them
I have a very simple scenario involving a database and a JMS in an
I have a following scenario in my SQL Server 2005 database. zipcodes table has
Scenario: I have an application (C#) that expects a SQL database and login, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.