473,666 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

some features needed

Every time I create ASP.NET pages that do any significant data access, I
find myself having to deal with the same problems: managing data object
creation, the SQL connection object especially.

Problem 1: If I have a pile of data adapters on a page, I typically only
need a single SQL connection object, though the designer always tries to add
a new one for each data adapter. So I have to manually weed out the extras
and set the data adapters to use the same connection object. I should be
able to default VS.NET to that behavior instead of doing extra work every
time.

Problem 2: The connection string is static in the designer. It ought to
provide a dynamic means.

I'm constantly having to struggle with the designer vs. what happens at
runtime. For example, when I am creating pages that are going to be
deployed at some client's site, they are going to want some means to
configure the connect string. Obviously I can stick it in the registry or
some CFG file and give them a simple UI means of changing it. However, the
designer generates code that executes when the page loads. If I modify that
code, then the designer gets confused. If, on the other hand, I change the
SQL object dynamically at run time, I can really only do that AFTER it has
already tried to create one for me...one with the wrong connect string.
It's a chicken/egg thing.

One possible solution would be to allow me to specify a function that
returns the connect string instead of the string itself. There are a couple
of other ways one could approach this, but I'll cut it off there.

Problem 3: Object creation....all data objects are created from the ground
up every time the page loads. When I have pages which use more than a
couple of data adapters, that starts to add up, and often I don't really
need most of those objects on every page load, I may only need a few. So,
for optimization, I tend to copy/paste code generated in the designer into
separate functions so that I have the flexibility of creating those objects
when they are actually needed. Of course, I have to leave the old objects
in there and just comment them out at release time or else I lose the nice
features that the designer gives me. Option 2 is I create all of them on a
separate page, then copy/paste the code to the page I actually need them on.
That way I can continue to use the designer, but then I have to
re-copy/paste everything when I make modifications.

It might be nice to give this one some in-depth consideration and come up
with a more elegant solution than just "fire up all the data objects every
time the page loads". Maybe the VS.NET team could add a simple feature such
as a way to demarcate a chunk of code as belonging to the designer so that
all the generated code would not neccessarily HAVE to be lodged in a known
function. Then I could move out the chunks to where I need them without
totally blowing away the designer. I'd have no problem with it generating
the code in the usual place by default, of course.

Jul 21 '05 #1
2 1329
Sounds to me like you want to create all of your DataAdapters and SQLConection objects at runtime instead of dropping them onto the designer

For preference I would not personally use the designer for any objects without a UI, or at least a large numer of properties that would remain static for the duration of the program.
Jul 21 '05 #2
I think I have came across you of your issues, and may be able to help.

Problem 1.
Not sure if this really helps, but it sounds like your getting into some
intense apps. As good or bad VSS works with data objects, you will have to
draw the line and say. This need to be in a data access layer. So, using a
data access layer (DAL) will get rid of the data objects like data adapters
all together in your asp.net page. There are some very good free ones as
well, but I highly recommend llblgen pro if you can get it, or the free
version is just fine to.

Problem 2.
Maybe dynamic properties will help you. You can find these in the properties
window. They work with your app.conf or web.conf to populate settings. And
if you are deploying to a client site and all that have to do deploy the app
is edit the web.config or app.config, and run a db script. Then, you have
done most everything right.

Problem 3.
I somewhat agree with you, but this is just the tip of the whole stateless
iceberg. It gets even worse to create web controls on the fly. (make sure
you set those id's) it also seems that using a data access layer will keep
you from doing allot of that copying and pasting. You also may want to look
into learning more about OO design. Take a look at your Option 2 for this
problem. You could create a class, and create shared functions, and just put
imports mysharedfunctio ns at the top of your page. No more copying into
pages, you can just include them in where you need. But there even better
ways of doing this, such as a DAL, or what they used to call components
(assemblies). Separate your app into 3 sections, Presentation, DAL and
datasource. Allot of your problems will go away. As well as being able to
update and maintain your code easier.

I would agree that these and other issues as well seem like a mountain to
overcome from time to time, but I truly believe that MS did us all a favor
with .NET and ASP.NET, and VSS.NET was a godsend. The implementation of
these technologies I believe were made with good intention as well.
(Remember, nothing is perfect)

Oh, and if you need some examples of any of this, take a look at the
quickstart tuts from asp.net

Hope this helps.

Chris Smith
"John Viele" <jo************ **@hummingbird. com> wrote in message
news:e6******** ******@TK2MSFTN GP12.phx.gbl...
Every time I create ASP.NET pages that do any significant data access, I
find myself having to deal with the same problems: managing data object
creation, the SQL connection object especially.

Problem 1: If I have a pile of data adapters on a page, I typically only
need a single SQL connection object, though the designer always tries to add a new one for each data adapter. So I have to manually weed out the extras and set the data adapters to use the same connection object. I should be
able to default VS.NET to that behavior instead of doing extra work every
time.

Problem 2: The connection string is static in the designer. It ought to
provide a dynamic means.

I'm constantly having to struggle with the designer vs. what happens at
runtime. For example, when I am creating pages that are going to be
deployed at some client's site, they are going to want some means to
configure the connect string. Obviously I can stick it in the registry or
some CFG file and give them a simple UI means of changing it. However, the designer generates code that executes when the page loads. If I modify that code, then the designer gets confused. If, on the other hand, I change the SQL object dynamically at run time, I can really only do that AFTER it has
already tried to create one for me...one with the wrong connect string.
It's a chicken/egg thing.

One possible solution would be to allow me to specify a function that
returns the connect string instead of the string itself. There are a couple of other ways one could approach this, but I'll cut it off there.

Problem 3: Object creation....all data objects are created from the ground
up every time the page loads. When I have pages which use more than a
couple of data adapters, that starts to add up, and often I don't really
need most of those objects on every page load, I may only need a few. So,
for optimization, I tend to copy/paste code generated in the designer into
separate functions so that I have the flexibility of creating those objects when they are actually needed. Of course, I have to leave the old objects
in there and just comment them out at release time or else I lose the nice
features that the designer gives me. Option 2 is I create all of them on a separate page, then copy/paste the code to the page I actually need them on. That way I can continue to use the designer, but then I have to
re-copy/paste everything when I make modifications.

It might be nice to give this one some in-depth consideration and come up
with a more elegant solution than just "fire up all the data objects every
time the page loads". Maybe the VS.NET team could add a simple feature such as a way to demarcate a chunk of code as belonging to the designer so that
all the generated code would not neccessarily HAVE to be lodged in a known
function. Then I could move out the chunks to where I need them without
totally blowing away the designer. I'd have no problem with it generating
the code in the usual place by default, of course.

Jul 21 '05 #3

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

Similar topics

4
2747
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like storing products in
22
2309
by: bearophile | last post by:
Ville Vainio: >It's highly typical for the newbies to suggest improvements to the >language. They will usually learn that they are wrong, but the >discussion that ensues can be fruitfull anyway :-). Few more notes on the language. I don't know if I can really suggest improvements to the language... but I hope to learn something :-) I think some things are better in Delphi/Pascal (like the := for assignments instead of = and = for...
9
2073
by: TPJ | last post by:
First I have to admit that my English isn't good enough. I'm still studying and sometimes I just can't express what I want to express. A few weeks ago I've written 'Python Builder' - a bash script that allows anyone to download, compile (with flags given by user) and install Python and some external modules (e.g. wxPython, PyGTK, Numeric...). I use Python every day and when new version of Python (or some external module) is released, I...
5
1346
by: Ralph2 | last post by:
Hello The person responsible for installing software at work believes in installing the bare minimum., which does not include the option to split a data base into a front and back end. So, rather than "beg" will any CD work to install more features. Or, will the add features look for the original CD only. Office 2000 installed and I would use my copy of the same program. Thanks
193
9521
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
48
2154
by: yezi | last post by:
Hi, all: I want to record some memory pointer returned from malloc, is possible the code like below? int memo_index; int i,j; char *tmp; for (i=0;i<10;i++){
1
992
by: John Viele | last post by:
Every time I create ASP.NET pages that do any significant data access, I find myself having to deal with the same problems: managing data object creation, the SQL connection object especially. Problem 1: If I have a pile of data adapters on a page, I typically only need a single SQL connection object, though the designer always tries to add a new one for each data adapter. So I have to manually weed out the extras and set the data...
21
1783
by: Jim | last post by:
I am trying to write an HTTP/HTTPS proxy server in VB.Net 2005. But, I don't really even know how the internal workings of a proxy should act. Does anyone have anything on the protocols used in handling requests by proxies? I have Googled my eyes out....and found nothing. (BTW, props to Google for refusing the ridiculous request for their search results.)
11
1424
by: Sachin Garg | last post by:
I need to build two executables from my code, one having all the code (and thus application features) and other not having it all. How to best manage the code that shouldn't go in one of the executables? My first thought is to use conditional compilation with #define and #ifdef etc but its getting messy, are there better ways to manage this? The problem in detail: #. There is a class A with virtual foo1 and foo2
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.