null exception

rjhe22

Well-known member
Joined
May 22, 2008
Messages
88
Programming Experience
Beginner
having a problem have this code and it works



VB.NET:
        Dim tbl As New DataTable("InvestmentComment") 


        Dim gidInv As Guid = CType(CType(Me.bndInvestmentMain.Current, DataRowView).Row.Item("InvestmentID"), Guid) 
        Me._data.LoadGUID(tbl, gidInv, "InvestmentID") 



        tbl.Columns("InvestmentID").DefaultValue = gidInv 

        Me.bndComments.DataSource = tbl 
        Me.grdInvestmentComment.DataSource = Me.bndComments 
        Me.navComments.BindingSource = Me.bndComments 

        Me.grdInvestmentComment.Columns.Remove("UserID") 
        Dim col As New DataGridViewComboBoxColumn 
        col.Name = "UserID" 
        col.HeaderText = "User Name" 
        col.DataSource = Me._user 
        col.ValueMember = "UserID" 
        col.DisplayMember = "FullName" 
        col.DataPropertyName = "UserID" 
        col.AutoComplete = True 
        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells 
        col.SortMode = DataGridViewColumnSortMode.Automatic 
        Me.grdInvestmentComment.Columns.Add(col) 
        If tbl.Rows.Count > 0 Then 
            Me.txtComment.Enabled = True 
        End If 
        col.Dispose()



trying to do the same thing with this code but it does not work any ideas anyone



VB.NET:
        Me._note = New DataTable("BankNote") 
        Dim gidInv As Guid = CType(CType(Me.bndBankNote.Current, DataRowView).Row.Item("BankAccountID"), Guid) 
        Me._data.LoadGUID(Me._note, gidInv, "BankAccountID") 
        ' Dim gidInv As Guid = CType(CType(Me.bndBankNote.Current, DataRowView).Row.Item("userID"), Guid) 

        ' Me._data.LoadGUID(Me._note, gidInv, "UserID") 
        Me._data.LoadProc(Me._note) 
        Me.grdBankNotes.DataSource = Me._note 
        'Me.grdBankNotes.DataSource = Me.bndBankAccount 
        'Me.navBankAccount.BindingSource = Me.bndBankAccount 
        Me.grdBankNotes.Columns("BankNoteID").Visible = True 
        Me.grdBankNotes.Columns("BankAccountID").Visible = True 
        Me.grdBankNotes.Columns("BankNote").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill 



        Me.grdBankNotes.Columns.Remove("UserID") 
        Dim col As New DataGridViewComboBoxColumn 
        col.Name = "UserID" 
        col.HeaderText = "User Name" 
        col.DataSource = Me._user 
        col.ValueMember = "UserID" 
        col.DisplayMember = "FullName" 
        col.DataPropertyName = "UserID" 
        'Me.txtNote.DataBindings.Clear() 
        'Me.txtNote.DataBindings.Add("Text", Me.bndBankAccount, "BankNote") 
        col.AutoComplete = True 
        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells 
        col.SortMode = DataGridViewColumnSortMode.Automatic 
        Me.grdBankNotes.Columns.Add(col) 
        If Me.grdBankNotes.Rows.Count > 0 Then 
            Me.txtNote.Enabled = True 
        End If
 
When I run into a Null Exception I step through the code to see what value is null and work from there to see why it null. Also post the exact error you are getting and we may be able to help you better.
 
Back
Top