473,413 Members | 1,989 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,413 software developers and data experts.

How would you do it? dataset, class, ... ???

Hi,

I have a database with 40000 articles... (it is a shop) ... there are
columns like price, stock, name, short description, long description etc....
the long description could be really much text.

How would you programm the connection to the database in a shopapplication?

1. DataSet with all articles (and all data) in it for every user of the
webpage?
2. Class "article" (with properties price,stock,name,... )
2.1. get the values of the properties on first use (connect everytime for
every property to database and fetch it)
2.2. get all values for the article in advance (on creation of an object of
the class)
3. another (which?) way?

Which solution would you choose?

Thanks a lot

alex
Feb 1 '06 #1
3 900
Dan
Like you would with any application, why do you think it would be different
because it is a shop? Database is a database regardless of what it stores.

So as and when you need info from the db open a connection, run your sql,
close it straight away.

I personally made a wrapper class with all my db functionality, that way i
could do something like:

dbClass _dbObj = new dbClass();

int _productid;

float sellingPrice = _dbObj.GetProductPrice(_productid);

and so on... Makes life much easier, then if you change your db structure
all your sql commands are in that db class and you need only change them
there.

--
Dan
"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> wrote in
message news:Ou**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a database with 40000 articles... (it is a shop) ... there are
columns like price, stock, name, short description, long description
etc.... the long description could be really much text.

How would you programm the connection to the database in a
shopapplication?

1. DataSet with all articles (and all data) in it for every user of the
webpage?
2. Class "article" (with properties price,stock,name,... )
2.1. get the values of the properties on first use (connect everytime for
every property to database and fetch it)
2.2. get all values for the article in advance (on creation of an object
of the class)
3. another (which?) way?

Which solution would you choose?

Thanks a lot

alex

Feb 1 '06 #2
at the moment i do it like you...
every time a article is "loaded" (an object ist created), the values for the
properties are fetched from the database.
If i create many objects of the class "article" then there are many
datasource.open() and datasource.close() operations.... and there is for
every article a SELECT-operation.
isn't that inefficient? or doesn't matter that?


"Dan" <dv*******@aol.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP14.phx.gbl...
Like you would with any application, why do you think it would be
different because it is a shop? Database is a database regardless of what
it stores.

So as and when you need info from the db open a connection, run your sql,
close it straight away.

I personally made a wrapper class with all my db functionality, that way i
could do something like:

dbClass _dbObj = new dbClass();

int _productid;

float sellingPrice = _dbObj.GetProductPrice(_productid);

and so on... Makes life much easier, then if you change your db structure
all your sql commands are in that db class and you need only change them
there.

--
Dan
"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> wrote in
message news:Ou**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a database with 40000 articles... (it is a shop) ... there are
columns like price, stock, name, short description, long description
etc.... the long description could be really much text.

How would you programm the connection to the database in a
shopapplication?

1. DataSet with all articles (and all data) in it for every user of the
webpage?
2. Class "article" (with properties price,stock,name,... )
2.1. get the values of the properties on first use (connect everytime for
every property to database and fetch it)
2.2. get all values for the article in advance (on creation of an object
of the class)
3. another (which?) way?

Which solution would you choose?

Thanks a lot

alex


Feb 1 '06 #3

Find this post:
Page Cannot Be Found - DNS Error
Tuesday, January 31, 2006 4:55 PM
and check my 2 replies.

...

To add to your discussion:

You could.
When a Product is requested:::(say productid = 123 for example)

1. If your ProductCollection doesn't exist, then create it.
2. If your ProductionCollection exists.. then check it to see if it has
Product with ProductID = 123
3. If so, then return it.
4. If not, call a another class to read the database, create an
IDataReader, and return the Product
5. .Add it to your ProductCollection
6. ?Re-persist our Collection.

...

Or you can get the whole shooting match of products, and put them in your
ProductCollection.

That is an architectural decision you'll have to make. It depends on if
people are accessing most of your products (where i'd put them all in the
Collection up front) OR.. .they access a few of them more often. (I'd do
the 6 steps above).

...
"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> wrote in
message news:u6**************@TK2MSFTNGP15.phx.gbl...
at the moment i do it like you...
every time a article is "loaded" (an object ist created), the values for the properties are fetched from the database.
If i create many objects of the class "article" then there are many
datasource.open() and datasource.close() operations.... and there is for
every article a SELECT-operation.
isn't that inefficient? or doesn't matter that?


"Dan" <dv*******@aol.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP14.phx.gbl...
Like you would with any application, why do you think it would be
different because it is a shop? Database is a database regardless of what it stores.

So as and when you need info from the db open a connection, run your sql, close it straight away.

I personally made a wrapper class with all my db functionality, that way i could do something like:

dbClass _dbObj = new dbClass();

int _productid;

float sellingPrice = _dbObj.GetProductPrice(_productid);

and so on... Makes life much easier, then if you change your db structure all your sql commands are in that db class and you need only change them
there.

--
Dan
"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> wrote in
message news:Ou**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a database with 40000 articles... (it is a shop) ... there are
columns like price, stock, name, short description, long description
etc.... the long description could be really much text.

How would you programm the connection to the database in a
shopapplication?

1. DataSet with all articles (and all data) in it for every user of the
webpage?
2. Class "article" (with properties price,stock,name,... )
2.1. get the values of the properties on first use (connect everytime for every property to database and fetch it)
2.2. get all values for the article in advance (on creation of an object of the class)
3. another (which?) way?

Which solution would you choose?

Thanks a lot

alex



Feb 2 '06 #4

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

Similar topics

1
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have...
2
by: theWizK | last post by:
Hello all. I have noticed that when I generate a strongly-typed dataset from an xml schema that the DataTables that are generated have their constructors marked as internal. What this means is...
2
by: JS | last post by:
I'm trying to create a data layer and having problems returning a DataSet from my code that's in a class module. Please forgive me. I'm new to C# (VB'er). I decided to create my data layer in...
10
by: localhost | last post by:
I have a static, thread-safe class with a DataSet as a property. When the class is instanced into an object, some callers add rows to a DataTable in the DataSet. Other callers read the DataSet. ...
3
by: James Morton | last post by:
I am writing a c# windows forms application. I read in an XML file to a dataset for read-only access (by the user and the application logic). This is not an MDI app but has LOTS of seperate...
2
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have...
2
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and...
2
by: Jim Heavey | last post by:
Hello I turned Option Strict on and after I did, I am getting an error of "Option Explicit does not allow late binding". OK great, now it is time to learn how to create a strongly typed dataset....
2
by: Gary Shell | last post by:
I have jumped in to the deep end of the pool, trying out visual inheritance of a form and have run into a snag. I have the need to create a simple maintenance form for five identically...
8
by: GaryDean | last post by:
In an 2.0 asp app I used vs.net 2005 to create a TableAdapter:Dataset in my App_code directory. I also created a new vb class in that same directory. I have two issues: 1. I notice that there...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.