pass tableadapter as parameter to module

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 1
Reputation: jedimaster100 is an unknown quantity at this point 
Solved Threads: 0
jedimaster100 jedimaster100 is offline Offline
Newbie Poster

pass tableadapter as parameter to module

 
0
  #1
Nov 28th, 2008
Hi guys! There's something that's been bugging me for a while. I have an application which contains many windows forms and each have one or more connections to the database.

All connections have been made using the Data Source Configuration Wizard which ends up adding three important data objects to a form namely Dataset1, CustomersBindingSource and CustomersTableAdapter (if the source table is Customers). Now in each form I have an update event which goes like this:
--------------------------------------------------------------------------------------
  1. 'Try to save changes
  2. Dim changedRecordsTable As System.Data.DataTable = Me.DataSet1.Customers.GetChanges()
  3. Dim changedRecords As Boolean = Not (changedRecordsTable Is Nothing) AndAlso (changedRecordsTable.Rows.Count > 0)
  4. Dim message As String
  5. 'Change message if there are changes
  6. If changedRecords = True Then
  7. message = String.Format("You are about to update {0} record(s)." + vbCrLf + "Do you want to continue?", changedRecordsTable.Rows.Count)
  8. Else
  9. 'No changes
  10. message = String.Format("Do you want to continue?")
  11. End If
  12. Dim messageReply As System.Windows.Forms.DialogResult = MessageBox.Show(message, Me.Text & " Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  13. 'If reply is yes save changes
  14. If messageReply = Windows.Forms.DialogResult.Yes Then
  15. Try Me.CustomersTableAdapter.Update(Me.DataSet1.Customers)
  16. Catch exc As Exception
  17. End Try
  18. End If
  19. --------------------------------------------------------------------------------------

Now this works well however since all my forms have that update subroutine, I was thinking of passing all data objects to a module and all my forms would be calling the module with appropriate parameters only. But I cannot seem to pass CustomersTableAdapter as a parameter. Is there another way to do this?
Last edited by jedimaster100; Nov 28th, 2008 at 12:42 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC