Jump to content
  • Advertisement
Sign in to follow this  
Holland

[.net] DataTable.ImportRow() question

This topic is 3347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does DataTable.ImportRow() take into account duplicates? In other words, if I try and import and exact duplicate row, will it import it anyways, or will it not since there is already a duplicate in there?
bool isActive; // true if the "Active Only" checkbox is checked
bool isValid;  // true if the "Valid Only" checkbox is checked

DataTable mainTable = GetMainTable();

DataTable newTable = mainTable.Clone();

if (isValid)
{
    DataRow[] rows = mainTable.Select("isValid = true");
    foreach (DataRow r in rows)
    {
        newTable.ImportRow(r);
    }
}

if (isActive)
{
    DataRow[] rows = mainTable.Select("startDate <= '" + DateTime.Now.ToShortDateString() + "' AND finishDate >= '" + DateTime.Now.ToShortDateString() + "'")
    foreach (DataRow r in rows)
    {
        newTable.ImportRow(r);
    }
}


There might be some rows that would be active AND valid, and thus those rows would be imported in duplicate. But will ImportRow() catch this or not?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!