wigno
Wed Aug 31 05:42:39 CDT 2005
Thank you very much for all your support.
Now,
my datagrid is binded to a dataview.
I have solved my problem using updating the database in the event
ListChanged of my dataview.
Deleted rows creates problem in this event so i put the code
to delete the row in the event CurrentCellChanged of my datagrid.
Now all works fine... i have a connected datagrid
thanks
Dim merging As Boolean = False
Private Sub dvDocArticoli_ListChanged(ByVal sender As Object, ByVal e
As System.ComponentModel.ListChangedEventArgs) Handles
dvDocArticoli.ListChanged
If (dsDati.HasChanges(DataRowState.Added)) And Not merging Then
merging = True
daDocArticoli.Update(dsDati.DOCUMENTI_ARTICOLI)
dsDati.AcceptChanges()
merging = False
End If
If dsDati.HasChanges(DataRowState.Deleted) And Not merging Then
Exit Sub
End If
If dsDati.HasChanges() And Not merging Then
merging = True
daDocArticoli.Update(dsDati.DOCUMENTI_ARTICOLI.GetChanges())
dsDati.AcceptChanges()
merging = False
End If
End Sub
On Wed, 31 Aug 2005 10:14:32 +0200, Cor Ligthert [MVP]
<notmyfirstname@planet.nl> wrote:
> Wigno,
>
> I tested it with this and had no problems.
> (I had problems with that haschanges however that is not your problem
> and I
> did not look further to it).
>
> I think that the trick is that adding from the handler after that the
> datasource is set.
>
> \\\
> Private da As SqlDataAdapter
> Private ds As New DataSet
> Private Sub Form1_Load(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> Dim conn As New SqlConnection("Server=Kamer;" & _
> "DataBase=Northwind; Integrated Security=SSPI")
> Dim sqlstr As String = "SELECT * FROM Employees"
> da = New SqlDataAdapter(sqlstr, conn)
> da.Fill(ds)
> DataGrid1.DataSource = ds.Tables(0)
> AddHandler ds.Tables(0).RowChanged, AddressOf dt_RowChanged
> End Sub
> Private Sub Button1_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button1.Click
> If ds.Tables(0).Rows(2)("FirstName").ToString = "Janet" Then
> ds.Tables(0).Rows(2)("FirstName") = "Marie"
> Else
> ds.Tables(0).Rows(2)("FirstName") = "Janet"
> End If
> End Sub
> Private Sub dt_RowChanged(ByVal sender As Object, _
> ByVal e As System.Data.DataRowChangeEventArgs)
> Dim cmb As New SqlCommandBuilder(da)
> da.Update(ds)
> End Sub
> ///
>
> I hope this helps,
>
> Cor
>
>
--
Using Opera's revolutionary e-mail client:
http://www.opera.com/mail/