Matt wrote:
Have below code
AcctNbr give me result of 30.
That is the database column length, Column stores 10 why is giving me
30 ?
while(objRead.Read())
{
AcctNbr = (string)objRead[0].ToString().Length;
Console.WriteLine("Length is {0}",AcctNbr.Length);
}
I don't know that I have an answer to your question but it seems what
you are doing here isn't quite right.
This line returns the length of objRead after converting it to a string.
This value is an integer. You then convert that integer into a
string. So AcctNbr now hold something like 10 in string form.
AcctNbr = (string)objRead[0].ToString().Length;
Here you take your string value of 10 and get the length of that string
value. so the answer to AcctNbr.Length would be 2. I don't think this
is what you ment to do.
Console.WriteLine("Length is {0}",AcctNbr.Length);
Chris