| | |
pass tableadapter as parameter to module
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 1
Reputation:
Solved Threads: 0
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:
--------------------------------------------------------------------------------------
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?
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:
--------------------------------------------------------------------------------------
VB.NET Syntax (Toggle Plain Text)
'Try to save changes Dim changedRecordsTable As System.Data.DataTable = Me.DataSet1.Customers.GetChanges() Dim changedRecords As Boolean = Not (changedRecordsTable Is Nothing) AndAlso (changedRecordsTable.Rows.Count > 0) Dim message As String 'Change message if there are changes If changedRecords = True Then message = String.Format("You are about to update {0} record(s)." + vbCrLf + "Do you want to continue?", changedRecordsTable.Rows.Count) Else 'No changes message = String.Format("Do you want to continue?") End If Dim messageReply As System.Windows.Forms.DialogResult = MessageBox.Show(message, Me.Text & " Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) 'If reply is yes save changes If messageReply = Windows.Forms.DialogResult.Yes Then Try Me.CustomersTableAdapter.Update(Me.DataSet1.Customers) Catch exc As Exception End Try End If --------------------------------------------------------------------------------------
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.
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Localization of MSFlexgrid
- Next Thread: execute one insert query and two update query, in one single button click.
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview map mobile module monitor msaccess mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview regex remove reuse right-to-left save search searchvb.net serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year





