[dba-VB] Calling SP with params from C# sample

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Sat Nov 28 03:19:35 CST 2009


John --

Tons of code for C# (or VB.NET) is not an issue at all. And for C#/VB.Net
programmers also. You'll get adapted to that reality soon, I believe. I have
projects with literally thousands of custom classes - they work in
production for several years without any issues. And they recompile from
cleaned solution with 10+ projects in 10+ seconds. And when you're working
on such solution and change code/recompile/run then recompiling and
restarting takes <1-2 seconds as VS recompiles/rebuilds only changed
projects. Have a look e.g. on DotNetNuke(DNN) sources - and if you'll try to
"dig them out" you'll find how "ugly" DNN sources are sometimes...

For your case I'd use:

- plain "dumb" manual coding if you have relatively static set of SPs and
their parameters;
- LINQ for SQL (now);
- ADO.NET Entity Framework (VS2010);
- statically generated custom classes to call SPs and process SPs' results.

I'd not use dynamically generated SqlCommand and SqlParameters as this
approach could result in too much and never ending "plumbing programming"...

And in all the cases you can use the power of true OOP C# provides to
minimize "copy and paste" coding approach...

BTW, C# 4.0 provides some very powerful dynamic programming features - more
powerful than late binding(?) - I must say I have seen some samples of that
new C# 4.0 features usage but I didn't get how to use them :) - maybe they
can help you to minimize "ugliness" of your C# coding but be careful to not
spend too much time on "plumbing programming"...

http://stackoverflow.com/questions/244302/what-do-you-think-of-the-new-c-4-0
-dynamic-keyword

http://geekswithblogs.net/sdorman/archive/2008/11/16/c-4.0-dynamic-programmi
ng.aspx 

--
Shamil

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Saturday, November 28, 2009 6:45 AM
To: Discussion concerning Visual Basic and related programming issues.
Subject: Re: [dba-VB] Calling SP with params from C# sample

Shamil,

I executed my first SP using your example code (first light as they say in
the astronomy world).

Man oh man is it ugly though.  Tons of code to get one lonely little SP to
execute (NOT your fault!!!).

Thank you so much for the examples, I can definitely take it from here.

John W. Colby
www.ColbyConsulting.com


Shamil Salakhetdinov wrote:
> Hi John -
> 
>  
> 
> Here is a sample for you:
> 
>  
> 
> public static void TestSP()
> 
> {
<<< snip >>>
 

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4643 (20091127) __________

The message was checked by ESET NOD32 Antivirus.

http://www.esetnod32.ru
 




More information about the dba-VB mailing list