VB Data Access Layer

  • I am looking to create a generic data access layer for SQL Server that will allow me to run any stored procedure using the same method. I know in princle this can be done but I've never seen any code out there to do it! Does anyone know of any articles written about this?

    In basic terms, I want a function "ExecuteSP" with three parameters for the name of the stored procedure, an array of values to pass as the paramters when calling the stored procedure and thirdly an optional byref recordset to return db results. If anyone has done something similar or can point me in the direction of some code I would be very greatfull.

    Thanks in advance

    Jon

  • If you hit msdn.microsoft.com you should be able to find the source for the FMStocks project, has something similar. More recently they released the source for the data access block for .Net, very much worth looking at.

    DAL's are a good idea, but stored procs still require a fair amount of set up code to handle the params - I use a code generator for them so it doesnt hurt much.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • Microsoft has created a series of building blocks for .Net development. There is a data layer building block which is great. See http://www.microsoft.com/downloads/details.aspx?FamilyID=76fe2b16-3271-42c2-b138-2891102590ad&displaylang=en

    There is methods in this data layer class that allow you to call any stored proc. An alternative is to use a product like LLBLGen (a both open source and professional version are available) helps create a great data access layer. I have used the free version before and although there is no generic (call any stored proc ) method the product generates the appropriate method and generates the stored proc.

    There exists also an exception (error handling) block see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp

    I have used the Microsoft blocks in projects and they are a timesaver.

    Francis

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply