Re: Is there a better way to do this

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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" <kahsiang.wong@xxxxxxxxx> schreef in bericht news:1190939342.158701.70370@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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?


.



Relevant Pages

  • How can I pass a different class and method name to a component?
    ... foreach (DataRow dr in dt) ... // Get pk or OrderDate ... I would like to reuse common code by putting it into a base class. ... and then call "MoveOrders" method with one integer parameter. ...
    (microsoft.public.dotnet.framework)
  • Re: Member field could be one of two types...
    ... In trying to enforce encapsulation I have a member field called connection which could be a type of SQLConnection, ... So you could encapsulate your connection as either of those classes, or even one of the intermediate ones. ... Should I be using a base class that contains all of the common methods, and then setup concrete classes that setup the data specific fields, methods? ... The base class would include the members that don't care what the type of the connection is, while the derived classes would include the members that are specific to the type of connection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Has anyone ever implemented a Decorator pattern in VB?
    ... The idea is to add functionality to the base class. ... reference to an instance of the base class, ... I have a Connection object and a TimedConnection bject. ... callback function to a timing server. ...
    (microsoft.public.vb.general.discussion)
  • RE: already an open DataReader associated with this Connection
    ... code that gets the datareader from the base class. ... In the finally, we close the reader, close the connection ...
    (microsoft.public.dotnet.framework.adonet)
  • already an open DataReader associated with this Connection
    ... There is already an open DataReader associated with this ... Connection which must be closed first. ... used by our getreader method in our base class. ... Protected Overrides Function getConnection() As ...
    (microsoft.public.dotnet.framework.adonet)