Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Stored procs or a C# class to access database

Options
  • 03-05-2007 12:17pm
    #1
    Registered Users Posts: 981 ✭✭✭


    I've just written a database for SQL 2005 to manage my games collection and have decided to use C# to make a Windows Forms front end for it. This is also a learning excercise for me since I've only developed ACT and Sage Line 50 mods using C# as opposed to a full blown application.

    It's all going fine but I'm having a bit of a design dilemma...

    I've been taking a look at all the cool record set stuff in ADO.net and working if I should manage the logic for adding/editing/deleting records in a Database controller class of sorts as opposed to writing stored procedures to do the same functionality.

    I come from a database background so I'm comfortable enough setting up all the stored procs I need but my current job has me working more as an application developer so I was thinking it might be nice to put all of those cool classes in ADO.net to use.

    If I go for a C# class it's no big deal to reuse that for other interfaces to my app as time goes on like ASP.net, Web services etc but I would be limited to the .Net platforms.

    With stored procs I'm sticking to what I know even though in my mind it's a little clucky trying to write application functionality in T-SQL.

    I'm swaying towards doing it in C# but I was wondering if anyone else had an opinion on the matter?


Comments

  • Closed Accounts Posts: 2,616 ✭✭✭8k2q1gfcz9s5d4


    it would be better to use stored procedures, they are faster and more secure than embedded SQL in code when it comes to running an app on the net. It is how it is done in the industary.


  • Registered Users Posts: 995 ✭✭✭cousin_borat


    Agreed, ADO etc are abstractions from the database and as such will never be able to do as good a job as the database in terms of transaction management, etc etc.

    There is a argument for both approaches, one particularly vehement one on theserverside. I side with keeping as much transactional logic as possible on the database.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    Using prepared SQL is just as safe as a stored procedure. I prefer the "database work gets done in the database" kind of mentality. In other words, i prefer stored procedures which i just call from my code.


  • Registered Users Posts: 981 ✭✭✭fasty


    Thanks folks, I ended up doing a little bit of both. I wrote some stored procs to act as an interface to the database then wrote a controller class in C# that took record sets and passed the data in them to the stored procs. Likewise reading info from the DB was done like that and the data returned to my UI in a record set.


Advertisement