フィールドがデータベースのテーブルに実際に存在するかどうかを検証したいと思います。データの読み取りにSqlDataReaderクラスを使用しました。SqlDataReaderに値を割り当てた後、foreachを使用して各レコードを反復処理するループを作成しました。これがサンプルコードです。
SqlCommand sqlCommand = new SqlCommand();
SqlDataReader sqlDr = sqlCommand.ExecuteReader();
Foreach(DbDataRecord record in sqlDr)
{
// Validate if the value is not null and (I want to validate if this field really exist in the table)
if(record["MyField1"].GetType().ToString() == "System.DBNull")
{
// Statement here
}
}
親切な回答をお願いします。どうもありがとうございます。