Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hard-coding column names

Status
Not open for further replies.

tektipster79

Programmer
Oct 1, 2007
34
US
I'm using a datareader to iterate through recordsets, and I'm doing a lot of this:

Employee.FirstName = dataReader["FirstName"]...

This "feels" wrong because there are a lot of hard-coded column names, but I don't see a way around it that doesn't seem a whole lot more work than it's worth.

Thanks!
 
You could make it a variable, so that you only hard code in one place.

Code:
string firstCol = "FirstName";
...
Employee.FirstName = dataReader[firstCol];

Slightly better solution....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top