Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 158975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:46:37+00:00 2026-05-11T10:46:37+00:00

My current application is using an instance based data access layer. I instantiate the

  • 0

My current application is using an instance based data access layer. I instantiate the layer with the connection string. I then call a method that will do some sort of command. For example there is a method that will fill a dataset. Basically, I pass the stored procedure and any SQL parameters and get back a dataset. Is it better to have a static class to handle my data access or an instance based? I do have a Domain layer with objects, but I am not mapping the objects like an ORM would. I am passing the objects into factories that then instantiates the data layer to pull back a dataset. I then map the dataset to the object. I plan on updating my app (and yes moving to C#), but I do not have the time to change the entire thing. I do the same thing for inserts updates, and Deletes. If what I am doing is OK for now, let me know. Do you see any issues with this approach? Otherwise, what should I be doing? I did not write this class. I found it on-line and thought this is what I needed.

Here is an example of the data class:

Public Sub New(ByVal connectionString As String)         _connectionString = connectionString     End Sub  Public Function FillDataset(ByVal cmd As String, ByVal cmdType As CommandType, Optional ByVal parameters() As SqlParameter = Nothing) As DataSet         Dim connection As SqlConnection = Nothing         Dim command As SqlCommand = Nothing         Dim sqlda As SqlDataAdapter = Nothing         Dim res As New DataSet         Try             connection = New SqlConnection(_connectionString)             command = New SqlCommand(cmd, connection)             command.CommandType = cmdType             AssignParameters(command, parameters)             sqlda = New SqlDataAdapter(command)             sqlda.Fill(res)         Catch ex As Exception             'CreateDataEntry(ex, WriteType.ToFile, cmd)         Finally             If Not (connection Is Nothing) Then connection.Dispose()             If Not (command Is Nothing) Then command.Dispose()             If Not (sqlda Is Nothing) Then sqlda.Dispose()         End Try         Return res     End Function           Public Function ExecuteNonQuery(ByVal spname As String, ByVal ParamArray parameterValues() As Object) As Object         Dim connection As SqlConnection = Nothing                     Dim command As SqlCommand = Nothing         Dim res As Object = Nothing         Try             connection = New SqlConnection(_connectionString)             command = New SqlCommand(spname, connection)             command.CommandType = CommandType.StoredProcedure             command.Parameters.AddRange(parameterValues)             connection.Open()             command.ExecuteNonQuery()             res = command.Parameters(command.Parameters.Count - 1).Value          Catch ex As Exception             CreateDataEntry(ex, WriteType.ToFile, spname)             If Not (transaction Is Nothing) Then                 transaction.Rollback()             End If                         Finally             If Not (connection Is Nothing) AndAlso (connection.State = ConnectionState.Open) Then connection.Close()             If Not (command Is Nothing) Then command.Dispose()                         End Try         Return res     End Function 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:46:37+00:00Added an answer on May 11, 2026 at 10:46 am

    First, I think that the instance-based approach is correct. Using static classes will make it much more difficult to unit test your DAL and to mock your DAL out when unit testing other classes. Second, I think you ought to reconsider building your own DAL. You’ll invest a lot of time in creating, maintaining, and testing your DAL when you could, by using an existing (well-tested) ORM — like LINQtoSQL, nHibernate, nTier, or even Entity Framework — spend more time on code that directly benefits your business needs. I’ve done both, hand-built DAL and the ORM, in my case LINQtoSQL, and I’ve found that I spend much less time testing (and fixing) my DAL going the ORM route.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 194k
  • Answers 195k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By default the frame of a JFrame is native. This… May 12, 2026 at 6:52 pm
  • Editorial Team
    Editorial Team added an answer When you run the tnameserv you'll have to kill it… May 12, 2026 at 6:52 pm
  • Editorial Team
    Editorial Team added an answer Vertex indexing (i.e., glDrawElements) can greatly reduce the size of… May 12, 2026 at 6:52 pm

Related Questions

I'm in the process of adding a Data Access Layer for our ASP.Net 2.0
I'm implementing a custom Flex component that provides a scrollable viewpoint onto a (possibly
I am writing an application that logs status updates (GPS locations) from devices to
I have embedded Ruby inside my C++ application. I have generated the bindings using

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.