C# Get a column value using a string?

Voro

New Member
Is it possible using C# to get the value of a column using a string as opposed to an integer? sqldatareader.getvalue() is not overloaded to accept strings. I can forsee this being a major pain in the *** if a query is changed and all of a sudden you have to go through all of your code to change the column numbers.Just do:<BR><BR>dr["columnName"];<BR><BR>You don't have to use .GetValue(). There is an Item property. If you have the docs installed locally, check out:<BR>ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataSqlClientSqlDataReaderMembersTopic. htm<BR>D'oh! I completely overlooked the Item property when I was running through the docs. By using Item will it still return the correct type(ie. int, datetime, etc...)?<BR><BR>Also, how can you use get/set with arrays?
 
Back
Top