System.Data.SqlClient.SqlDataReader.SqlDataReader.GetOrdinal C# (CSharp) Method

GetOrdinal() public method

public GetOrdinal ( string name ) : int
name string
return int
		int GetOrdinal (string name)
		{
			ValidateState ();

			if (name == null)
				throw new ArgumentNullException ("fieldName");

			string colName;
			foreach (TdsDataColumn schema in command.Tds.Columns) {
#if NET_2_0
				colName = schema.ColumnName;
				if (colName.Equals (name) || String.Compare (colName, name, true) == 0)
					return (int) schema.ColumnOrdinal;
#else
				colName = (string) schema["ColumnName"];
				if (colName.Equals (name) || String.Compare (colName, name, true) == 0)
					return (int) schema["ColumnOrdinal"];
#endif
			}
			throw new IndexOutOfRangeException ();
		}