473,406 Members | 2,956 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,406 software developers and data experts.

Is there a better way to do this

kah
Hi Guys,

In my ASP.net application, i am display information using a dataset.
e.g

for each datarow in dataset.table(0).rows
label.text=datarow.item("ColumnName").tostring
next

This works perfectly fine until i have to rename a column in my table.
Obviously the easiest way to make the change is search for all
instance of the Old Column Name and replace it with the New column
Name. However this set me thinking? Is there a better way to do this?

I am thinking of creating a base class with has all the column as the
properties of the table. An another class with is a collection of this
base class. So each time i retrieve a dataset from the db. For each
row of the dataset, i will create a new instance of the base class.
Populate it with the data of that row and add it to the collection.
>From there onwards, instead of using the dataset, i can use the
collection class to get all the values.

Am i doing it the right way or is there a better way to go about doing
it?

Sep 28 '07 #1
4 1452
kah,

Why don't you just reference the column by ordinal number instead of by name?

Kerry Moorman
"kah" wrote:
Hi Guys,

In my ASP.net application, i am display information using a dataset.
e.g

for each datarow in dataset.table(0).rows
label.text=datarow.item("ColumnName").tostring
next

This works perfectly fine until i have to rename a column in my table.
Obviously the easiest way to make the change is search for all
instance of the Old Column Name and replace it with the New column
Name. However this set me thinking? Is there a better way to do this?

I am thinking of creating a base class with has all the column as the
properties of the table. An another class with is a collection of this
base class. So each time i retrieve a dataset from the db. For each
row of the dataset, i will create a new instance of the base class.
Populate it with the data of that row and add it to the collection.
From there onwards, instead of using the dataset, i can use the
collection class to get all the values.

Am i doing it the right way or is there a better way to go about doing
it?

Sep 28 '07 #2
kah
Hi Kerry,

If i was to reference by ordinal number instead, the application would
be tightly coupled with the table.
In future whenever i change the table, I have to make sure that i do
not changed the sequence.

When writing the code, i will would have to look up to find out which
column i am refering to.

Regards,
Kah


On Sep 28, 11:15 am, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
kah,

Why don't you just reference the column by ordinal number instead of by name?

Kerry Moorman

"kah" wrote:
Hi Guys,
In my ASP.net application, i am display information using a dataset.
e.g
for each datarow in dataset.table(0).rows
label.text=datarow.item("ColumnName").tostring
next
This works perfectly fine until i have to rename a column in my table.
Obviously the easiest way to make the change is search for all
instance of the Old Column Name and replace it with the New column
Name. However this set me thinking? Is there a better way to do this?
I am thinking of creating a base class with has all the column as the
properties of the table. An another class with is a collection of this
base class. So each time i retrieve a dataset from the db. For each
row of the dataset, i will create a new instance of the base class.
Populate it with the data of that row and add it to the collection.
>From there onwards, instead of using the dataset, i can use the
collection class to get all the values.
Am i doing it the right way or is there a better way to go about doing
it?

Sep 28 '07 #3
Kah,

What is a name in this case more than a mnemonic, it should not have any
connection with the outside world, you can for the same use an index, or as
Kerry wrote the column itself.

There is only a very limited speed change (much less than milliseconds
absolute to ignore on internet). The slowest the index, the quickest the
column.

Cor

"kah" <ka***********@gmail.comschreef in bericht
news:11*********************@n39g2000hsh.googlegro ups.com...
Hi Guys,

In my ASP.net application, i am display information using a dataset.
e.g

for each datarow in dataset.table(0).rows
label.text=datarow.item("ColumnName").tostring
next

This works perfectly fine until i have to rename a column in my table.
Obviously the easiest way to make the change is search for all
instance of the Old Column Name and replace it with the New column
Name. However this set me thinking? Is there a better way to do this?

I am thinking of creating a base class with has all the column as the
properties of the table. An another class with is a collection of this
base class. So each time i retrieve a dataset from the db. For each
row of the dataset, i will create a new instance of the base class.
Populate it with the data of that row and add it to the collection.
>>From there onwards, instead of using the dataset, i can use the
collection class to get all the values.

Am i doing it the right way or is there a better way to go about doing
it?
Sep 28 '07 #4
well after reading your question and the comments

I guess you could use a BL ( Business Logic ) component , however when
you change the data structure you must change the data logic in the BL
component
you can not get around this , However the big advantage of a BL is that you
only need to change this in one place ( the BL ) and all other projects that
use the BL are automaticly updated when the BL is updated .

if you want more info regarding a BL design i would say investigate a
distributed design pattern, or ask here :-)
regards

Michel Posseth
"kah" <ka***********@gmail.comschreef in bericht
news:11*********************@n39g2000hsh.googlegro ups.com...
Hi Guys,

In my ASP.net application, i am display information using a dataset.
e.g

for each datarow in dataset.table(0).rows
label.text=datarow.item("ColumnName").tostring
next

This works perfectly fine until i have to rename a column in my table.
Obviously the easiest way to make the change is search for all
instance of the Old Column Name and replace it with the New column
Name. However this set me thinking? Is there a better way to do this?

I am thinking of creating a base class with has all the column as the
properties of the table. An another class with is a collection of this
base class. So each time i retrieve a dataset from the db. For each
row of the dataset, i will create a new instance of the base class.
Populate it with the data of that row and add it to the collection.
>>From there onwards, instead of using the dataset, i can use the
collection class to get all the values.

Am i doing it the right way or is there a better way to go about doing
it?

Sep 28 '07 #5

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

Similar topics

9
by: ForHimself Every Man | last post by:
What's better about Rattlesnakes than Python. I'm sure there's something. What is it? This is not a troll. I'm a snake shooping and I want people's answers. I don't know beans about...
10
by: michael newport | last post by:
Dear friends of database(s), After 13 years of Ingres, I am now using Oracle. But is Oracle technically better than Ingres. I would be much obliged if anyone could shed some light on the...
24
by: Faith Dorell | last post by:
I really don´t like C.You can write better programs in BASIC than in C, if you don´t like this language. I don´t understand how C became so popular, although much better programming languages...
39
by: bazad | last post by:
Hi, I am not using C all the time. I have a general understanding of C and nothing else. The recent reply to use strlcpy and strlcat showed me that I am not aware of the best and safe...
2
by: monkeydragon | last post by:
Which is better, using ReadFile/WriteFile or use fstream?
33
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
21
by: gavino | last post by:
why?
3
by: Ryan Liu | last post by:
Hi, Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than synchronous I/O? At least as good? When I don't concern about easy or difficult to write code, should I always...
43
by: Pawel_Iks | last post by:
I've read somewhere that c++ is something more than better c ... then I talk with my friend and he claimed that c++ is nothing more than better c ... I tried to explain him that he was wrong but I...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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...

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.