SafeDataReader invalid indexSafeDataReader invalid index
Old forum URL: forums.lhotka.net/forums/t/6145.aspx
KFoster posted on Tuesday, January 13, 2009
Our business object layer is developed somewhat independently from the database. Sometimes a new requirement implies a new field in the result set from a stored proc. The BO puts the code in place, and pushes to development environment before the DBA has done their part. And...boom! Doesn't work. What would be nice is a method in SafeDataReader to see if a key exists before using it.
if (sdr.KeyExists("NewColumn"))
{
newField = sdr.GetString("NewColumn");
}
Am I missing something and this already exists? Or is there a workaround for this behavior?
Thanks,
Kendaniel_higgins replied on Tuesday, January 13, 2009
Can you cast to IDataReader and use FieldCount and GetName() ?Copyright (c) Marimer LLC