Hello;
I have a form with BindingNavigator control and i'm working with disconected mode using classic objects ( SqlConnection,SqlDataAdapter,and DataSet ...) , what i want to do is to work with this BindingNavigator with my dataset without using graphical mode to
bind my BindingSource .. and i did it , the add button works fine when i saved my work ..but the problem with my delete button .. it rises an exception like this
"Concurrency violation: the DeleteCommand affected 0 of the expected 1 records."
hope you understand me .. and thanks for helping me !
Private cnx As New SqlConnection("data source=" + My.Computer.Name + ";initial catalog=MYDB;integrated security=true")
Private da As New SqlDataAdapter("SELECT * FROM trainee", cnx)
Private cb As New SqlCommandBuilder(da)
Private ds As New DataSet
Private bs As New BindingSource
Private Sub GetData()
Try
cnx.Open()
If cnx.State = ConnectionState.Open Then
da.Fill(ds, "trainee")
Else
Throw New Exception
End If
Catch ex As Exception
MsgBox("Problem of connexion", MsgBoxStyle.Critical, "Error")
End Try
End Sub
Private Sub DoBinding()
bs.DataSource = ds.Tables(0)
BindingNavigator1.BindingSource = bs
txtNom.DataBindings.Add("text", BindingSource1, ds.Tables(0).Columns(1).ColumnName, True)
txtPrenom.DataBindings.Add("text", BindingSource1, ds.Tables(0).Columns(2).ColumnName, True)
txtFiliere.DataBindings.Add("text", BindingSource1, ds.Tables(0).Columns(3).ColumnName, True)
End Sub
Private Sub Client_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GetData()
DoBinding()
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
Me.Validate()
BindingSource1.EndEdit()
da.Update(ds, "trainee")
Member
3 Points
41 Posts
BindingNavigator and delete button !!
Jun 14, 2012 09:22 AM|bhd44hsk5|LINK
Hello;
I have a form with BindingNavigator control and i'm working with disconected mode using classic objects ( SqlConnection,SqlDataAdapter,and DataSet ...) , what i want to do is to work with this BindingNavigator with my dataset without using graphical mode to bind my BindingSource .. and i did it , the add button works fine when i saved my work ..but the problem with my delete button .. it rises an exception like this "Concurrency violation: the DeleteCommand affected 0 of the expected 1 records."
hope you understand me .. and thanks for helping me !
Star
9210 Points
2981 Posts
Re: BindingNavigator and delete button !!
Jun 14, 2012 12:57 PM|Mudasir.Khan|LINK
please check this
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/aa46d0d1-11b8-4af7-b66e-e14715df54fd/
http://msdn.microsoft.com/en-us/library/cc917674.aspx
All-Star
94130 Points
18109 Posts
Re: BindingNavigator and delete button !!
Jun 14, 2012 10:37 PM|Decker Dong - MSFT|LINK
Are you using WebForm or WinForm?I suspect you are using WinForm;So please directly send your question to:
Windows Forms Data Controls and Databinding
Reguards!