I have several asp labels that I'm putting sql table values into. The field is 10 characters long max and is varchar type. I know for a fact the data is varchar and it's value is not X, and it's never null. A typical value for this field would be something like: 4"W 2"T Could the quotations cause this problem? For some reason the value that gets returned is "X" instead of the size field in my table. I'm scratching my head on this. I can only assume the X represents an issue converting the data or maybe it doesn't fit in the provided cell space? I did try making the label width wider and it didn't change. I even changed the label name to be sure it wasn't a mishandling of the label. This is the line in question:
lblList1.Text = "Size: " + sqlRdr.GetValue(18);
When the data is returned it will display this regardless what the value is: Size: X
I tried sqlRdr.GetValue(18).ToString; just to make sure if there were odd values that it will still be string format. Anyone else know how an X could be returned?
Loading
Sam HobbsPosted Feb 9, 2010, 2:12 PM
Are you sure that column 18 is the correct column? Note that 18 is column 19 if the first column is 1. The index used by the SqlDataReader.GetValue Method is zero-based.