|
-
Jul 14th, 2008, 10:33 AM
#1
Thread Starter
Hyperactive Member
[2005] Best practices and Modules question
I am new to ASP.Net 2.0. In my ASP.Net 1.1 project I had a Module that exposed public functions that returned Datasets, Datareaders etc from the database.
I cannot seem to find the Module Template in ASP.Net 2.0, does this not exist anymore?
Also, should I be using a Module in this form. The only problem with a class is that I would have to instantiate it on every page when I want to connect to the Database.
-
Jul 14th, 2008, 10:47 AM
#2
Frenzied Member
Re: [2005] Best practices and Modules question
You can use a Class in the same way.
Class.Yourmethod will work withouth instantiating it. As long as Yourmethod is Public.
-
Jul 14th, 2008, 11:04 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Best practices and Modules question
 Originally Posted by Besoup
You can use a Class in the same way.
Class.Yourmethod will work withouth instantiating it. As long as Yourmethod is Public.
Do you know if that is considered the best way? I want my database access code in a separate place than the form code behind.
-
Jul 14th, 2008, 11:04 AM
#4
Re: [2005] Best practices and Modules question
 Originally Posted by Besoup
You can use a Class in the same way.
Class.Yourmethod will work withouth instantiating it. As long as Yourmethod is Public.
You mean Static (as in C#) or Shared (as in VB).
-
Jul 14th, 2008, 11:08 AM
#5
Frenzied Member
Re: [2005] Best practices and Modules question
 Originally Posted by maikeru-sama
Do you know if that is considered the best way? I want my database access code in a separate place than the form code behind.
Pretty sure it's the best way... It's what I do in my VS 2005 web apps.
Yeah, I stand corrected on the declaration.. Harsh is right!
-
Jul 14th, 2008, 11:11 AM
#6
Re: [2005] Best practices and Modules question
 Originally Posted by maikeru-sama
Do you know if that is considered the best way? I want my database access code in a separate place than the form code behind.
Actually it largely depends on the type of application you are working on.
Search here and google for 3-tier application in .Net. There may exists different tiered and may be non-tiered ways for accomplishing the thing.
It is generally considered good to separate database layer from the rest of application.
You may also want to look into different Patterns and Practices at MSDN site.
-
Jul 14th, 2008, 01:19 PM
#7
Re: [2005] Best practices and Modules question
I don't know what the Module Template is so you probably should describe it a bit better.
Yes, it's alright to call a function on every page. Rule of thumb in ASP.NET is to open your connection as late as possible and close it as soon as possible, so that makes it perfectly acceptable to call a database open connection method on every page (or from a method that you call which in turn opens a connection).
-
Jul 14th, 2008, 01:23 PM
#8
Thread Starter
Hyperactive Member
Re: [2005] Best practices and Modules question
When I say Module Template, I mean adding a Module to the project.
After doing some research, I read that you cannot add a Module to a ASP.Net 2.0 project and that Microsoft is probably trying to get rid of them. This was nothing official from Microsoft, but someone's opinion, with regards to Modules going away.
I think you all are right. I just wanted to make sure that I am doing things the right way or one of the accepted ways when programming in ASP.Net 2.0.
When I get time, I am going to make a Class that has shared functions that is used to access my data.
I am interested in Encrypting the connection string inside of Web.Config, so I will probably move on to that in few.
-
Jul 14th, 2008, 01:29 PM
#9
Re: [2005] Best practices and Modules question
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|