How to Display Values not exist on Lookup(DB)?
PartNumbers Loaded :
P0001 - Not on DB
P0002 - Not on DB
P0003 - On DB
P0004 - On DB
Code:
int i = 0;
//Loop Records per Row
foreach (var serverA in load)
{
var obj = new Bal();
var ent = new Entity
{
PartNumber = serverA.PartNumber.ToString()
};
_dSet = obj.SelectPartNumber(ent);
//CHECK IF PART NUMBER EXIST ON DB
if (_dSet.Tables[0].Rows.Count > 0)
{
}
else
{
i++; //Count Part Numbers not exist on DB
}
}
lblStatus.Text = i > 0 ? @"PartNumbers not on DB" : @"Data has been Loaded";
In this Code:( i ) value is equal to 2 and Display PartNumbers not on DB.
My Problem is how can i displ开发者_Go百科ay the part numbers that do not exist on DB and display it on any container(Message Box etch.).
Ex:
PartNumber Not on DB
P0001
P0002
Thanks in Regards!
Where you're incrementing the count you probably want to add the part number to a list. you can then use the list to generate the text to display. Using a StringBuilder
instead of a list would probably work okay, too.
//CHECK IF PART NUMBER EXIST ON DB
if (_dSet.Tables[0].Rows.Count > 0)
{
}
else
{
i++;
builder.Append(serverA.Partnumber.ToString()).AppendLine();
}
}
if(i > 0 )
{
MessageBox.Show(builder.ToString());
}
else
{
lblStatus.Text = @"Data has been Loaded";
}
精彩评论