This code:
string numString = "000" + dReader["Code"].ToString();
If the value is
2
, you will get
0002
.
But if the value is
200
, you will get
000200
, which I think is not what you want.
If the value is
200
, the outcome should be
0200
.
You can use
PadLeft()
to solve this:
while (dReader.Read())
{
string number = dReader["Code"].ToString().PadLeft(4, '0'));
}