- Jun 8, 2005
- 360
- 0
- 76
If you can put an 'if' conditional statement in either a mssql stored procedure or in the C# source, which would be better in terms of performance and structure? Would it matter?
Originally posted by: drebo
Definitely the stored procedure.
If you put it in the C#, you have to pull the conditional data to figure out which other data you need to pull. In the stored procedure, it (presumably) already has access to that data, and thus your ODBC/ADO/whatever data connector only needs to pull one set of data.
Originally posted by: Hmongkeysauce
It's actually a rather simple block of code.
adapter = (lang == "eng") ? adapter = new SqlDataAdapter("pullEngArticles", con) : adapter = new SqlDataAdapter("pullOtherArticles", con);
I originally had that conditional statement in the stored procedure and passing in the parameter @lang. Benchmarks showed that leaving the conditional statement out in the C# code is about .0004 seconds faster.That may not matter but when you start having a few of these on the same page, it may start adding up.
