473,386 Members | 1,734 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,386 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 1448
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
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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
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,...

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.