Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check the dataset databindings duplicate key or n
Message
From
26/05/2011 11:41:29
 
 
To
22/05/2011 10:03:05
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01511207
Message ID:
01511857
Views:
34
>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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform