Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Practice - .Net Class

Status
Not open for further replies.

Johnblaze1

Programmer
Sep 17, 2002
25
US
I have a best practice question.
I have a class that I want to use amongst multiple applications.
The class is dependent on several large SQL statements to perform its job.
What is the best practice for including the SQL statements (approx 10) with the class itself?
Should I use constants in the class, or is there a more elegant solution?

Thanks in advance

John
 
If the SQL statements are large because they are complex, you should create stored procedures and execute these by name as this will speed up the execution time.
 
Do the SQL statement change or just the variables?
 
techsmith - I dont have the option to create stored procedures.

djj55 - the statements are static, I just change the parameters as needed.

Thanks

John
 
Is there information you want to store in this object related to the data returned? Or are you just wanting to return the data and be done with the object?

If you want to retain data, a standard class would be the way to go. A public method to launch the process of retreiving values, and public properties used to expose the data you are looking for.

If you do not want to retain the data, a module or shared class would work well. Modules and Shared classes work with out instantiation. They are a collection of shared members (methods, properties, etc) that can be referenced with out instantiating the class.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
ThatRickGuy

Im really just wanting the store approx 10 SQL statements that the class uses. I am inquiring if its better to store them in an XML file and make the class dependent on that XML file being present. Or, is there some cleaner way. I want to have this class portable accross several applications

Thanks

John
 
Why store them in XML? Do they need to be changed?

Create a library project, add a new class, create the members you need (defined as shared), and add references to that library project from any other applications that need access to that data.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top