Jump to content
  • Advertisement
Sign in to follow this  
Holland

[.net] DataTable.ImportRow() question

This topic is 3265 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!