[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

create Data layer

When creating DAL, data layer, I generally create something like below to return dataset.  

Public Function Fill_Grid() As DataSet
        Dim ds As New DataSet
        Using Sqlcon As New SqlConnection(WebConfigurationManager.ConnectionStrings("myConnectionString").ToString)
            Using SqlComnd As New SqlCommand("mysp", Sqlcon)
                SqlComnd.CommandType = CommandType.StoredProcedure
                Using sqlAD As New SqlDataAdapter(SqlComnd)
                    sqlAD.Fill(ds)
                End Using
            End Using
        End Using
        Return ds
    End Function

My question is when I create SqlDataSource1 like below, how would I create my DAL? Or Do I even need it?




 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
                            SelectCommand="mysp" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
0
VBdotnet2005
Asked:
VBdotnet2005
  • 2
2 Solutions
 
Chinmay PatelEnterprise ArchitectCommented:
No. ASP.Net will take care of it for you. I don't think that is the best way to consume data though.
0
 
VBdotnet2005Author Commented:
Would you just create a function to return dataset like above then?
"No. ASP.Net will take care of it for you. I don't think that is the best way to consume data though. ", Could you clarify this a bit?
0
 
Chinmay PatelEnterprise ArchitectCommented:
Sure. I would have written a big paragraph but this particular answer saved me, here: http://forums.asp.net/p/1543479/3766438.aspx
0
 
RouchieCommented:
There is an article here also about how to make functions like yours into reusable objects
http://www.codepal.co.uk/show/How_to_make_subroutines_and_functions_reusable_across_your_entire_aspnet_application
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now