Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check the dataset databindings duplicate key or n
Message
From
22/05/2011 01:03:23
 
 
To
20/05/2011 05:44:21
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:
01511380
Views:
39
Hi Alex,

You can do all your error-checking in your FormClosing event if you want to. Call a method to do the checking after you've done BindingSource.EndEdit(). If there are errors, then you'll obviously want to set e.Cancel = true and do nothing else.

Also, it's not a good idea at all to use user-entered fields for PKs!!! If possible, PKs should not contain meaningful data.

~~Bonnie



>Hi all,
> i have some difficult questions. i have a dataset( set a primary , b not null ) use databindings and one add, delete, save, exit buttion.
>Remark i use
>
>
> Private Sub Company_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
>
>        Me.Validate()
>        Me.CompanyBindingSource.EndEdit()
>
>        If ADataSet.HasChanges(DataRowState.Added Or DataRowState.Deleted Or DataRowState.Modified) Then
>            Dim drResult = New DialogResult()
>
>            drResult = MessageBox.Show("Data updated, Do you want to save before program exit?", "Exit program", MessageBoxButtons.YesNoCancel)
>
>            Select Case drResult
>                Case DialogResult.Yes
>                    CompanyBindingNavigatorSaveItem_Click(sender, e)
>                    DataGridView1.Dispose()
>                    e.Cancel = True
>                Case DialogResult.Cancel
>                    e.Cancel = True
>                Case DialogResult.No
>                    e.Cancel = False
>                    DataGridView1.Dispose()
>            End Select
>        End If
>
>    End Sub
>
>
>
>1. How can i check the user entry duplicate primary key , pop msg?
>2. If the user entry true primary key, but no entry b field, after he use BindingNavigator go to other position, how to check the b field not null
>3. How to check user press exit , then closing the form ,if primary key duplicate also colsing, no check him ?
>4. i have a datagirdview, the user entry the primary key but b field no entry , how to check him after he press save or add button ,
> and focus to null cell .
>
>Anyone can give some idea , i already find some days in internet but no information...... thank thank thank
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform