[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 93
  • Last Modified:

reference data

Here is my code:

 Private Sub frmCompInfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        'TODO: This line of code loads data into the 'CompanyInfo._CompanyInfo' table. You can move, or remove it, as needed.
        Me.CompanyInfoTableAdapter.Fill(Me.CompanyInfo._CompanyInfo)

    End Sub

then I go to update it off of a Save Button

Me.CompanyInfoTableAdapter.Update(Me.CompanyInfo._CompanyInfo.GetChanges)

AND I get this error

argument null exception was unhandled
 vb.net vs2012
0
MBHEY131
Asked:
MBHEY131
  • 7
  • 3
2 Solutions
 
Michael FowlerSolutions ConsultantCommented:
It sounds like one of the objects in the offending line has not been initiated.

Place a break point at this line and then check the values of the objects in the call.
0
 
MBHEY131Author Commented:
I tried that and all looks well
It loads to the form and all textboxes that it's bound to

<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), _
         Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")> _
        Public Overridable Overloads Function Update(ByVal dataTable As CompanyInfo.CompanyInfoDataTable) As Integer
            Return Me.Adapter.Update(dataTable) <<< Errors out here the datatable is nothing
        End Function

but it's passed from here

 Me.CompanyInfoTableAdapter.Update(Me.CompanyInfo._CompanyInfo.GetChanges)

I mouse over and the data is in the ta and the ds and dt??? all have proper data
I'm stumped Which doesn't take to much.
0
 
Michael FowlerSolutions ConsultantCommented:
You are passing the results of the method GetChanges not the datatable itself. What happens if you pass just Me.CompanyInfo._CompanyInfo.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MBHEY131Author Commented:
Well I don't get any errors and it seems to bring over the data table name correctly
But it will not update any changes I make to the table???

that's progress anyway - what do I do now?
0
 
Michael FowlerSolutions ConsultantCommented:
Update the table then pass it to the function eg

Me.CompanyInfo._CompanyInfo.GetChanges
Me.CompanyInfoTableAdapter.Update(Me.CompanyInfo._CompanyInfo)

Open in new window

0
 
MBHEY131Author Commented:
everything seems to be going where it should and be in the proper places
But - it still will not push the changes to the data table in the database????
0
 
MBHEY131Author Commented:
table gets updated properly because I have it on the scope in the debugger, but no dice.
0
 
MBHEY131Author Commented:
Does anybody have any other  advice - this issue is holding up my whole project basically
Should I populate straight from a SQL
0
 
MBHEY131Author Commented:
SOLVED:
In my situation you need to call:
     
  Me.CompanyInfoBindingSource.EndEdit()

        before:

        Me.CompanyInfo._CompanyInfo.GetChanges()
        Me.CompanyInfoTableAdapter.Update(Me.CompanyInfo._CompanyInfo)

And much joy will be had!!!
0
 
MBHEY131Author Commented:
Me.CompanyInfo._CompanyInfo.GetChanges()
        Me.CompanyInfoTableAdapter.Update(Me.CompanyInfo._CompanyInfo)

Got me on the right track
But:

        Me.CompanyInfoBindingSource.EndEdit()

Needed to be added
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now