Saving collection back to it's database table. vb 2005
IDE : VS 2005,
Platform : .NET 2.0,
Hey all I have a collection class that is populated from a SQL database.
Code: Public Class LocalAuthorityList
Inherits ComponentModel.BindingList(Of LocalAuthority)
#Region " Public Methods"
Public Shared Function Create(ByVal userid As Integer) As LocalAuthorityList
Dim userlacoll As LocalAuthorityList
userlacoll = New LocalAuthorityList
Dim dt As DataTable
dt = CAPSDAC.DAC.ExecuteDataTable("GetListOfLocalAuthoritiesbyUserID", DAC.Parameter("@UserID", userid))
For Each dr As DataRow In dt.Rows
With dr
userlacoll.Add(LocalAuthority.Create(dr))
End With
Next
Return userlacoll
End Function
#End Region
End Class
I have a form with a datagridview that is linked to a datasource of type object, specifically the LocalAuthorityList collection.
In the form's Load method I instantiate the collection and bind to the datasource like this:
Code: Me.LocalAuthorityListBindingSource.DataSource = LocalAuthorityList.Create(CAPSUserListCollectionDataGridView.Rows(0).Cells.Item("UserID").Value)
Note that the Datasource is a colection object, NOT a datatable.
How on earth do I go about saving any changes the user made in the datafridview back to the database?
Do I have to loop through every row and call and update query for each row, can I do it as a 1 step thing?
source :http://www.vbcity.com
-------------------------------------------------------
Trik Gambar Bergerak
Trik Gambar-dimouse
Trik hapus pwd mysql
Trik insertin to db
Trik jadi root dilinux
Trik jam-distatus-bar
Trik Koneksi-ke database
Trik Koneksi-msql-php
Trik lihat-database-mysql
Trik membahas-fungsi-else
Trik member-area
Rabu, 04 Februari 2009
Langganan:
Postingan (Atom)