[dba-VB] C# - Stored procedures working!

jwcolby jwcolby at colbyconsulting.com
Mon Nov 30 15:35:18 CST 2009


I would like to thank all of you for your assistance in getting my stored procedures working from C#.

My strategy was to design a StoredProcedure class which contained all of the data and code required 
to run any of the stored procedures that I have written so far.  We shall see whether I succeeded in 
that however I have a set of seven stored procedures that are required to export large tables in 
chunks to CSV files and I am successfully running all of those seven stored procedures and obtaining 
CSV files.

This StoredProcedure class has a command object and a set of about eight "Parameter" methods which 
wrap the code for creating standard parameters used over and over in my various stored procedures, 
parameters like DBName, TblName, PKStart, PKend etc, as well as the return value and errorno and 
errormsg parameters.

I then created an AccuzipExport class that "supervises" the Accuzip export process, i.e. holds all 
of the code to DEFINE these seven stored procedures, i.e. set up the required stored procedure class 
mentioned above for each of these seven SPs, and the specific parameters that each SP uses.  This 
class then has a method that calls three of the stored procedures to create a standard named table, 
fill it with sorted data and index it in preparation for creating chunk files.  After that the 
method sits in a while loop calling the remaining four stored procedures which create the chunk 
table, append a chunk of records to that, index it and then BCP it out.

All of this stuff now works.  This stuff was what the old Access database did, so I have essentially 
ported the Accuzip Export process to C#.  However I have successfully returned a success/fail return 
value as well as an error code / message in the C# version, whereas I never had that ability in the 
Access version so I am now in some respects ahead of where I was in Access.

There is more to do of course.  Now that I have a robust dev platform at my fingertips I can log the 
process from beginning to end, errors, times for each SP to execute, stuff like that.  And of course 
get the process status displaying on the form I use to start this process.  Eventually I need to get 
this export process running in a thread so that I can use the big picture application for other 
things while this export process runs.

But next comes the matching AccuzipInput class, which will pull the CSV files coming back from 
Accuzip back into SQL Server.  With all of the grunt work done for executing Stored Procedures it 
should be relatively quick and easy to get the matching input class up.

At any rate I wanted to say thanks to everyone for all the help and express how jazzed I am to be 
where I am today.

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list