Just to avoid unneccary Convet.ToInt32, while retrieving from an Int type
column in table.
> Other than math calculations, sorting will definitely be a problem, since
> text is sorted much differently than numbers
[quoted text clipped - 10 lines]
> >
> > Do you guys see anything wrong with this practice?
Lloyd Sheen - 18 Mar 2008 20:45 GMT
> Just to avoid unneccary Convet.ToInt32, while retrieving from an Int type
> column in table.
[quoted text clipped - 16 lines]
>> >
>> > Do you guys see anything wrong with this practice?
General rule of thumb. Do your database design. If a field is numeric then
use a number type. Don't mix presentation and data. Designing a database
for presentation sake will eventually come back to bite you and it is much
simpler to fix the presentation layer than your data.
LS
mavrick_101 - 18 Mar 2008 21:02 GMT
No, the data in the tables is still <B>int</B> or whatever. I'm talking about
when retrieving in .aspx code.
> > Just to avoid unneccary Convet.ToInt32, while retrieving from an Int type
> > column in table.
[quoted text clipped - 23 lines]
>
> LS
Lloyd Sheen - 18 Mar 2008 21:24 GMT
> No, the data in the tables is still <B>int</B> or whatever. I'm talking
> about
[quoted text clipped - 35 lines]
>>
>> LS
Sorry I am talking about database tables.
LS
Patrice - 19 Mar 2008 10:04 GMT
Humm how do you retrieve the data ? You shouldn't have to convert. You may
want to post a new thread about your original issue...
Actually I never even thought about not having the correct mapping (and I
don't even remember to have heard about doing such a thing)...
It has a potential to cause loads of problem (comparison, sort, type
checking etc...) or at best you'll have to change your code as soon as you
wan't to do actually something with this data + the conversion even if you
have to do one is not that a huge issue...
I would really use the correct mapping between the client side variables and
the server side data. As said earlier I suspect you have an earlier issue
you may want to post about...
--
Patrice
> Just to avoid unneccary Convet.ToInt32, while retrieving from an Int type
> column in table.
Hans Kesting - 19 Mar 2008 10:36 GMT
When your database column has an "int" type, you can easily do
something like:
DataRow dr = MyDataSet.Rows[0];
int i = (int)dr["MyIntColumn"];
but this will fail if there are "null"s in that column (the field will
then contain a DbNull.Value). In that case use this:
int ?i2 = dr["MyIntColumn"] as int?;
Hans Kesting
mavrick_101 explained :
> Just to avoid unneccary Convet.ToInt32, while retrieving from an Int type
> column in table.