You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
ExecuteStoredProc - this is for running stored procs on the database for CRUD operations.
GetRecordsetFromStoredProc - this is for retrieving data from the database via stored procs.
GetDataFromSQLStatement - this is for retrieving data from the database via a raw SQL query.
All the methods can accept variables being passed back and forth between the layer and the database.
Implementation
There are various examples of how to use the Data Access Layer in the module 'mdTestDataAccessLayer'. These examples include executingstored procs in the database to retrieve data, and for executing common CRUD operations. To give you a brief idea of how the layer works, here is anexample of getting data from SQL Server using a simple SQL statement:
Dim rstData As New ADODB.RecordsetDim oDBInstance As New clsDBInstanceDim oDatabase As clsDatabaseSet oDatabase = oDBInstance.GetSharedDatabase()Set rstData = oDatabase.GetDataFromSQLStatement("SELECT country_name, country_region FROM [dbo].[country]")rstData.MoveFirstDo While Not rstData.EOF Debug.Print rstData.Fields("country_name").Value & " " & rstData.Fields("country_region").Value rstData.MoveNextLoopoDBInstance.CloseSharedDatabase
About
Data Access Layer in VBA for connecting to SQL Server.