Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Long command in C#
Message
De
25/05/2008 11:47:01
 
 
À
25/05/2008 11:30:10
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01319251
Message ID:
01319418
Vues:
21
It's a good habit to just write all strings like queries with StringBuilder. As you know, something like a query will get modified overtime. Adding columns, filters, joins, etc. So it will get bigger. In the apps i work with all queries are of type StringBuilder.

>Hi Perry,
>
>That was interesting to read and something I did not know. At this level it wouldn't have made any difference based on the article but using this method could be deemed a bad habbit I guess. Thanks for the insight.
>Tim
>
>>Actually, you wouldn't want to do it this way. Since strings in dotnet are immutable, you are in reality building 4 separate strings with this operation. To do this properly, you should make sQuery of type Stringbuilder. And when you are ready to use the query do sQuery.ToString().
>>
>>Here's a little discussion on this topic:
>>
>>http://channel9.msdn.com/ShowPost.aspx?PostID=14932
>>
>>>In addition to those suggestions you can always do this:
>>>
>>>string sQuery = "SELECT ordinal_position, column_name, data_type, is_nullable ";
>>>sQuery += "FROM informatin_schema.Columns "
>>>sQuery += "WHERE table_name LIKE '%avClients%' ";
>>>sQuery += "ORDER BY ordinal_position";
>>>
>>>
>>>No reason to, but it is an option and sometimes useful.
>>>Tim
>>>
>>>>How do I code this query?
>>>>
>>>>
>>>>
>>>> string sQuery = "SELECT ordinal_position, column_name,data_type, is_nullable
>>>>                FROM information_schema.Columns WHERE table_name LIKE '%avClients%'
>>>>	            ORDER BY ordinal_position"
>>>>
>>>>
>>>>
>>>>I'm not sure how to continue or break each line.

(On an infant's shirt): Already smarter than Bush
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform