0 Replies - 365 Views - Last Post: 14 June 2012 - 07:47 AM Rate Topic: -----

#1 SnoBunny85  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 02-March 10

Target Invocation Exception

Posted 14 June 2012 - 07:47 AM

I am writing a TPS System program and am having an error that I cannot figure out. I am trying to load a window by right clicking and selecting an option. The menu section of it works correctly but when it goes to load the window I get an TargetInvocationException. I understand that it can't move data over if data doesn't exist but not sure how to fix it. I tried putting in an if statment but still get the error. Thanks


Public Class w_vehicles_edit

#Region "Menu"
    Private Sub bSave_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles bSave.ItemClick
        Save()
    End Sub

    Private Sub bCancel_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles bCancel.ItemClick
        Close()
    End Sub
#End Region

#Region "Window"
    Private Sub w_vehicles_edit_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        CheckForChanges = True
        db = New Model.TPSModelDataContext(My.Settings.TPSConnectionString)

        If (Sys_property_idSpinEdit Is Nothing) Then
            bs_vehicle.DataSource = (From a In db.t_vehicles)
        Else
            bs_vehicle.DataSource = (From a In db.t_vehicles Where a.sys_property_id = parm.sys_property_id).SingleOrDefault
        End If



    End Sub
#End Region

End Class



Here is the specific section throwing the error
If (Sys_property_idSpinEdit Is Nothing) Then
            bs_vehicle.DataSource = (From a In db.t_vehicles)
        Else
            bs_vehicle.DataSource = (From a In db.t_vehicles Where a.sys_property_id = parm.sys_property_id).SingleOrDefault
        End If




Is This A Good Question/Topic? 0
  • +

Page 1 of 1