C# Using Error Provider
private bool saveFlag =true;
bool addnewFlag =false;
duplicateCheck();
if (saveFlag)
{
}
public void duplicateCheck()
{
if (addnewFlag)
{
DAL.DataSetErrotProviderTableAdapters.item_catagoryTableAdapter AdapterCategory = new Hardware_Inventory.DAL.DataSetErrotProviderTableAdapters.item_catagoryTableAdapter();
DataTable dt = AdapterCategory.GetData(item_catagory_nameTextBox.Text);
if (dt.Rows.Count > 0)
{
errorProvider1.SetError(item_catagory_nameTextBox, "This Name Allready Enter In Database");
saveFlag = false;
}
else if (dt.Rows.Count == 0)
{
errorProvider1.SetError(item_catagory_nameTextBox, "");
saveFlag = true;
}
}
}