>1. I want to use code to check the duplicate primary key , then i can write a msg.But how to check ?You could check against the database.
>And i mainly problem , i can't use Me.CompanyBindingSource.EndEdit() to checking , use this statement will error...
>Becuase my dataset ( set a primary , b not allow null ), if primary key has entry ,but b not entry will error in
>Me.CompanyBindingSource.EndEdit() , no body how to check it ?You have a few options:
1) You can turn off the constraints in your DataSet (dsMyData.EnforceConstraints = false), check the b entry, then either report the error if there is one, or turn the constraints back on if everything is ok.
2) Use a try/catch to catch the constraint error.
~~Bonnie