473,378 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Code Re-use or classes

I've been coding in asp.net (vb) for a while now and I miss being able
to create functions in modules (like in ms access) so that I don't
need to reuse my code in all the code behind pages. I know that
creating classes is the accepted way to get around this in .net but I
have not been able to find documentation that can get me to where I
want to be. I'd like to have a class that will have a couple data
centric functions, like a function to execute an update string in sql,
or a function to return a dataset or datatable.
the only classes I've seen examples of return things like text boxes,
I'm looking to perform a database action and either return success or
return the result of a query.

Has anyone done this? or does everyone have multiple copies of blocks
of code that just connect to a db and return the datasets?
Nov 18 '05 #1
1 896
Code reuse is always bad... Why? Well because if you need to change
something, you have to search for all the places you've used that code to
make the change. If everything's central, it's far clearer, and much easier
to change.

You can do the same thing as you did with modules in classes, all you need
to do is create a new class, and create a "public static sub" or "public
static fuction", then reference this directly without having to create the
class, just as you would when accessing modules...

<MyClass>.<MyStaticPublicFunction>

Thanks.

Dan.

"robopro" <ro*****@gmail.com> wrote in message
news:1d**************************@posting.google.c om...
I've been coding in asp.net (vb) for a while now and I miss being able
to create functions in modules (like in ms access) so that I don't
need to reuse my code in all the code behind pages. I know that
creating classes is the accepted way to get around this in .net but I
have not been able to find documentation that can get me to where I
want to be. I'd like to have a class that will have a couple data
centric functions, like a function to execute an update string in sql,
or a function to return a dataset or datatable.
the only classes I've seen examples of return things like text boxes,
I'm looking to perform a database action and either return success or
return the result of a query.

Has anyone done this? or does everyone have multiple copies of blocks
of code that just connect to a db and return the datasets?

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rasmus Fogh | last post by:
Dear All, I need a way of writing strings or arbitrary Python code that will a) allow the strings to be read again unchanged (like repr) b) write multiline strings as multiline strings instead...
4
by: Irmen de Jong | last post by:
Hello, I don't understand why the following doesn't work. What I want to do is dynamically import some generated Python code and I'm doing this using compile and exec'ing it in the dict of a new...
4
by: Noen | last post by:
Im developing a game where the players will program their equipment with python. Are there any ways to run insecure code? I dont want the clients to mess with the server-code through their own...
1
by: Brian Beck | last post by:
Hi. I'm having some problems with code based directly on the following httplib documentation code: http://www.zvon.org/other/python/doc21/lib/httplib-examples.html I've included the code and...
1
by: Amit Kela | last post by:
Hey, I am getting the following error when I try to delete the contents of a recordset under a condition statement. Is there any way I can delete them without running into this error? I need to...
3
by: Wayne... | last post by:
I'm trying to make a sort of source code libary for some customers of commonly used code to save them a bit of time the problem I have is that although I can get the asp code into a field of an...
5
by: Otto Wyss | last post by:
I've written an application which is intended to act as a code sample "how to code applications with a well designed GUI". Since this code is intended to also act as a sample for beginners it...
16
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
1
by: ahammad | last post by:
Hello, I have written a fairly complex parsing tool that is used to parse information from company documents. The program works very well, but in order to insure that all the data is copied...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.