By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

Is there a better way to do this

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.