April 16, 2009 at 7:55 pm
I'm trying to understand what happens with numeric data types in HTML. I think that HTML needs to be in string/character data type. If I'm wrong, please correct me.
So if that is right, then if in SQL server I have an identifier that is a numeric data type, (let's say bigint), then what happens in ASP.NET to display the bigint in a browser. Does the bigint have to be converted to string?
And if it does, would it not be better from a performance standpoint to have string identifiers instead of numeric, for things that will be displayed on the Internet.
Thanks in advance for your time.
April 16, 2009 at 8:20 pm
HTML has nothing to do with datatype. You just have to append the value if BIGINT in HTML tags.
When it comes to the ASP.NET, finally IIS converts the ASP.NET page to an HTML page, cos that is Browser understands. Ex: even if you DataGrid in ASP.Net to display results, it internally converts the DataGrid into TD and TR So when you are displaying this in datagrid you don't specify the datatype of the value which you are trying to fetch. On the other hand when you are passing a value from Front-End to stored procedure then you have to follow the datatypes.
Let us know if you still have any questions.
April 18, 2009 at 6:59 pm
Thanks for your answer. So let me make sure that I understand exactly. What you are telling me is that "Yes, it is converted from bigint to character data. But you do not have to do that conversion yourself. ASP.NET automatically converts it to character data."
Is that what you are saying?
If so, then from a performance standpoint, would it not be better to use a string identifier instead of a numeric identifier?
April 18, 2009 at 7:40 pm
your confusing presentation layer with the data layer.
you could argue that all your data be stored as a bitmap/image, since that is how it is going to be presented.....hopefully it's obvious you don't want to do that for the following reasons.
everything that is displayed as html gets converted to text for presentation....but you don't store data that is going to be presented, you store it in the right datatype so it can be interpreted...
for example, if you store everyone at your company's paycheck amounts /money as string, how do you add it it?
you'd have to convert it back from text to money or decimal.
stankirk (4/18/2009)
Thanks for your answer. So let me make sure that I understand exactly. What you are telling me is that "Yes, it is converted from bigint to character data. But you do not have to do that conversion yourself. ASP.NET automatically converts it to character data."Is that what you are saying?
If so, then from a performance standpoint, would it not be better to use a string identifier instead of a numeric identifier?
Lowell
April 20, 2009 at 8:16 am
Thanks so much for responding.
You did answer my question by saying that numeric data types that will be displayed as HTML must converted to text. That's what I thought, and was trying to verify it.
Since conversion from a SQL server bigint data type to and from text would take a fair amount of overhead when done in real time, I'm thinking to do an offline conversion of the bigint data to text and store the data in a C# dictionary. That way it won't have to be converted back and forth between data types. It seems like that would help performance a good bit. Of course, I'll do performance testing to see just how much difference it makes.
April 20, 2009 at 8:38 am
I think you will find that it doesn't gain you any performance. int.parse() and .tostring() are very efficient. I would be more concerned that you now have a dictionary. (are you using a stringdictionary or a hashtable). If its a string dictionary it is just a list of string that will still have to be converted to an int. If it is a hashtable you now have an object that must be converted to an int. Now matter how you slice it there is always going to be some conversion from int to string. IMHO I would skip storing this in a dictionary. Any performance gain by not having to convert each value will be lost by the overhead of searching the dictionary. Not to mention that what is a relatively simple code behind now becomes more difficult to maintain because you have to always keep the dictionary in sync with the data being posted.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 20, 2009 at 1:39 pm
I was talking about using a C# generic dictionary, which is strongly typed. The key could be a numeric data type or a string data type. If I use a string data type for the key (the identifier), then I will not have to do any type conversion. The performance is very good.
And maintaining the dictionary is no trouble. I just put a few lines of code to rebuild it from the database every time the program starts. Since this is a long running program, that should not be a problem, even though there will be quite a bit of data to put in the dictionary.
I'm not seeing the difficulties that you are talking about.
April 20, 2009 at 1:48 pm
I thought this was an asp.net app? Would be more difficult to persist the dictionary across sessions unless you either compiled it or loaded it to each session. But if your performance if ok then i don't see an issue with it. :hehe: Whatever works best for your app is what you should do.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply