Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. datagridviewtextboxcell error on 350 characters

datagridviewtextboxcell error on 350 characters

Scheduled Pinned Locked Moved Windows Forms
helpdatabaseannouncement
19 Posts 2 Posters 63 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rhyde Marsh
    wrote on last edited by
    #1

    this i my first post, so i hope i am explaining it correctly, have a datagridview with a textboxcolumn. it is bind to a dataset my problem is when i update a record wiht more that 350 characters it give me a nullrefference error. the database is updated when i check the physical record but the application crash here is the function Private Sub m_maintenanceProcessor_WebsiteUpdated(ByVal sender As Object, ByVal e As Processors.EventArgs) Handles m_maintenanceProcessor.WebsiteUpdated Dim tempTable As MaintenanceDataSet.WebsitePageDownloadDataTable Try If e.Data.Contains("ModifiedRows") = False Then Exit Sub tempTable = CType(e.Data("ModifiedRows"), MaintenanceDataSet.WebsitePageDownloadDataTable) If tempTable.Rows.Count > 0 Then RemoveHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated Processor.Data.WebsitePageDownload.LoadingTable = True Processor.Data.WebsitePageDownload.Merge(tempTable, False) Processor.Data.WebsitePageDownload.LoadingTable = False Processor.Data.WebsitePageDownload.RejectChanges() AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated Processor.Data.WebsitePageDownload.Merge(tempTable) 'For Each row As DataRow In tempTable.Rows ' If row.RowError IsNot Nothing AndAlso row.RowError.Length > 0 Then ' MsgBox(row.RowError) ' End If ' ' MsgBox(row("URL").ToString) 'Next 'MsgBox(Processor.Data.WebsitePageDownload.Columns("defaultstatusid").MaxLength) Processor.Data.WebsitePageDownload.AcceptChanges() End If Catch ex As Exception MsgBox(ex.Message.ToString) End Try tempTable = Nothing Me.StatusMessage = String.Empty End Sub error gets thrown on acceptchanges

    L 1 Reply Last reply
    0
    • R Rhyde Marsh

      this i my first post, so i hope i am explaining it correctly, have a datagridview with a textboxcolumn. it is bind to a dataset my problem is when i update a record wiht more that 350 characters it give me a nullrefference error. the database is updated when i check the physical record but the application crash here is the function Private Sub m_maintenanceProcessor_WebsiteUpdated(ByVal sender As Object, ByVal e As Processors.EventArgs) Handles m_maintenanceProcessor.WebsiteUpdated Dim tempTable As MaintenanceDataSet.WebsitePageDownloadDataTable Try If e.Data.Contains("ModifiedRows") = False Then Exit Sub tempTable = CType(e.Data("ModifiedRows"), MaintenanceDataSet.WebsitePageDownloadDataTable) If tempTable.Rows.Count > 0 Then RemoveHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated Processor.Data.WebsitePageDownload.LoadingTable = True Processor.Data.WebsitePageDownload.Merge(tempTable, False) Processor.Data.WebsitePageDownload.LoadingTable = False Processor.Data.WebsitePageDownload.RejectChanges() AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated Processor.Data.WebsitePageDownload.Merge(tempTable) 'For Each row As DataRow In tempTable.Rows ' If row.RowError IsNot Nothing AndAlso row.RowError.Length > 0 Then ' MsgBox(row.RowError) ' End If ' ' MsgBox(row("URL").ToString) 'Next 'MsgBox(Processor.Data.WebsitePageDownload.Columns("defaultstatusid").MaxLength) Processor.Data.WebsitePageDownload.AcceptChanges() End If Catch ex As Exception MsgBox(ex.Message.ToString) End Try tempTable = Nothing Me.StatusMessage = String.Empty End Sub error gets thrown on acceptchanges

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Where does the error occur? Please edit your question and put <pre> tags around your code so it looks like:

      Processor.Data.WebsitePageDownload.RejectChanges()
      AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated

      and indicate exactly which line the error occurs on.

      R 1 Reply Last reply
      0
      • L Lost User

        Where does the error occur? Please edit your question and put <pre> tags around your code so it looks like:

        Processor.Data.WebsitePageDownload.RejectChanges()
        AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView_RowValidated

        and indicate exactly which line the error occurs on.

        R Offline
        R Offline
        Rhyde Marsh
        wrote on last edited by
        #3

        Thanks for your response. The error occur on the acceptchanges line

        Private Sub m_maintenanceProcessor_WebsiteUpdated(ByVal sender As Object, ByVal e As Processors.EventArgs) Handles m_maintenanceProcessor.WebsiteUpdated
        Dim tempTable As MaintenanceDataSet.WebsitePageDownloadDataTable

              Try
                  If e.Data.Contains("ModifiedRows") = False Then Exit Sub
                  tempTable = CType(e.Data("ModifiedRows"), MaintenanceDataSet.WebsitePageDownloadDataTable)
                  If tempTable.Rows.Count > 0 Then
                      RemoveHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView\_RowValidated
                      Processor.Data.WebsitePageDownload.LoadingTable = True
                      Processor.Data.WebsitePageDownload.Merge(tempTable, False)
                      Processor.Data.WebsitePageDownload.LoadingTable = False
                      Processor.Data.WebsitePageDownload.RejectChanges()
                      AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView\_RowValidated
        
        
                      Processor.Data.WebsitePageDownload.Merge(tempTable)
        
                      'For Each row As DataRow In tempTable.Rows
                      '    If row.RowError IsNot Nothing AndAlso row.RowError.Length > 0 Then
                      '        MsgBox(row.RowError)
                      '    End If
        
                      '    ' MsgBox(row("URL").ToString)
        
                      'Next
        
                      'MsgBox(Processor.Data.WebsitePageDownload.Columns("defaultstatusid").MaxLength)
                      Processor.Data.WebsitePageDownload.AcceptChanges()
                  End If
              Catch ex As Exception
                  MsgBox(ex.Message.ToString)
              End Try
              tempTable = Nothing
        
              Me.StatusMessage = String.Empty
        
          End Sub
        
        L 1 Reply Last reply
        0
        • R Rhyde Marsh

          Thanks for your response. The error occur on the acceptchanges line

          Private Sub m_maintenanceProcessor_WebsiteUpdated(ByVal sender As Object, ByVal e As Processors.EventArgs) Handles m_maintenanceProcessor.WebsiteUpdated
          Dim tempTable As MaintenanceDataSet.WebsitePageDownloadDataTable

                Try
                    If e.Data.Contains("ModifiedRows") = False Then Exit Sub
                    tempTable = CType(e.Data("ModifiedRows"), MaintenanceDataSet.WebsitePageDownloadDataTable)
                    If tempTable.Rows.Count > 0 Then
                        RemoveHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView\_RowValidated
                        Processor.Data.WebsitePageDownload.LoadingTable = True
                        Processor.Data.WebsitePageDownload.Merge(tempTable, False)
                        Processor.Data.WebsitePageDownload.LoadingTable = False
                        Processor.Data.WebsitePageDownload.RejectChanges()
                        AddHandler maintenanceDataGridView.RowValidated, AddressOf maintenanceDataGridView\_RowValidated
          
          
                        Processor.Data.WebsitePageDownload.Merge(tempTable)
          
                        'For Each row As DataRow In tempTable.Rows
                        '    If row.RowError IsNot Nothing AndAlso row.RowError.Length > 0 Then
                        '        MsgBox(row.RowError)
                        '    End If
          
                        '    ' MsgBox(row("URL").ToString)
          
                        'Next
          
                        'MsgBox(Processor.Data.WebsitePageDownload.Columns("defaultstatusid").MaxLength)
                        Processor.Data.WebsitePageDownload.AcceptChanges()
                    End If
                Catch ex As Exception
                    MsgBox(ex.Message.ToString)
                End Try
                tempTable = Nothing
          
                Me.StatusMessage = String.Empty
          
            End Sub
          
          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You will need to use your debugger to find out which reference in that line is invalid.

          R 1 Reply Last reply
          0
          • L Lost User

            You will need to use your debugger to find out which reference in that line is invalid.

            R Offline
            R Offline
            Rhyde Marsh
            wrote on last edited by
            #5

            what i know for a fact is the is a field that is set for 2000 characters but once this field goes over 350 the error gets triggered, other than that the application is fine

            L 2 Replies Last reply
            0
            • R Rhyde Marsh

              what i know for a fact is the is a field that is set for 2000 characters but once this field goes over 350 the error gets triggered, other than that the application is fine

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Rhyde Marsh wrote:

              what i know for a fact

              But that is hardly relevant. Somewhere in your application something is being triggered which causes a null reference to be used. The only way to discover where that is and why, is to do some detailed debugging.

              R 1 Reply Last reply
              0
              • R Rhyde Marsh

                what i know for a fact is the is a field that is set for 2000 characters but once this field goes over 350 the error gets triggered, other than that the application is fine

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                2000 characters? In which encoding? UTF16?

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                R 1 Reply Last reply
                0
                • L Lost User

                  Rhyde Marsh wrote:

                  what i know for a fact

                  But that is hardly relevant. Somewhere in your application something is being triggered which causes a null reference to be used. The only way to discover where that is and why, is to do some detailed debugging.

                  R Offline
                  R Offline
                  Rhyde Marsh
                  wrote on last edited by
                  #8

                  ok i will get to that. juss that i have been looking and and dont see where

                  1 Reply Last reply
                  0
                  • L Lost User

                    2000 characters? In which encoding? UTF16?

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                    R Offline
                    R Offline
                    Rhyde Marsh
                    wrote on last edited by
                    #9

                    sorry for the late response but data field is set to nvarchar 2000 and the MaxInputLength set at 2000

                    L 1 Reply Last reply
                    0
                    • R Rhyde Marsh

                      sorry for the late response but data field is set to nvarchar 2000 and the MaxInputLength set at 2000

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Rhyde Marsh wrote:

                      nvarchar

                      Good. Check the line

                      Processor.Data.WebsitePageDownload.AcceptChanges()

                      Set the cursor on the AcceptChanges method, hit F12. Set breakpoints there, and make sure that the method does not swallow the changes.

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                      R 1 Reply Last reply
                      0
                      • L Lost User

                        Rhyde Marsh wrote:

                        nvarchar

                        Good. Check the line

                        Processor.Data.WebsitePageDownload.AcceptChanges()

                        Set the cursor on the AcceptChanges method, hit F12. Set breakpoints there, and make sure that the method does not swallow the changes.

                        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                        R Offline
                        R Offline
                        Rhyde Marsh
                        wrote on last edited by
                        #11

                        not sure what you mean swallow, but the data is updated but there seems to be a problem when it returns to the UI

                        L 1 Reply Last reply
                        0
                        • R Rhyde Marsh

                          not sure what you mean swallow, but the data is updated but there seems to be a problem when it returns to the UI

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          Rhyde Marsh wrote:

                          not sure what you mean swallow,

                          I'm expecting a try-catch in that method that hides the exception that is thrown.

                          Rhyde Marsh wrote:

                          the data is updated but there seems to be a problem when it returns to the UI

                          Is the data updated beyond the 350-char mark? How do you know there's a problem? Do you have an exception and a stack-trace?

                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                          R 1 Reply Last reply
                          0
                          • L Lost User

                            Rhyde Marsh wrote:

                            not sure what you mean swallow,

                            I'm expecting a try-catch in that method that hides the exception that is thrown.

                            Rhyde Marsh wrote:

                            the data is updated but there seems to be a problem when it returns to the UI

                            Is the data updated beyond the 350-char mark? How do you know there's a problem? Do you have an exception and a stack-trace?

                            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                            R Offline
                            R Offline
                            Rhyde Marsh
                            wrote on last edited by
                            #13

                            yes it updates but then i get a nullrefference exception. so before the 350 mark it updates and refresh fine but anything after that i get the error

                            L 1 Reply Last reply
                            0
                            • R Rhyde Marsh

                              yes it updates but then i get a nullrefference exception. so before the 350 mark it updates and refresh fine but anything after that i get the error

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #14

                              Rhyde Marsh wrote:

                              nullrefference exception

                              I assumed that was fixed, based on your previous post. Can you post the entire stacktrace from the exception?

                              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                              R 1 Reply Last reply
                              0
                              • L Lost User

                                Rhyde Marsh wrote:

                                nullrefference exception

                                I assumed that was fixed, based on your previous post. Can you post the entire stacktrace from the exception?

                                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                R Offline
                                R Offline
                                Rhyde Marsh
                                wrote on last edited by
                                #15

                                no my problem was not solved, but i it seem to be on bug on microsoft side in the control s at System.Windows.Forms.DataGridView.ComputeVisibleColumns() at System.Windows.Forms.DataGridView.LayoutScrollBars() at System.Windows.Forms.DataGridView.ComputeLayout() at System.Windows.Forms.DataGridView.PerformLayoutPrivate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl) at System.Windows.Forms.DataGridView.ResetUIState(Boolean useRowShortcut, Boolean computeVisibleRows) at System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged_PreNotification(CollectionChangeAction cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow& dataGridViewRow, Boolean changeIsInsertion) at System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged(CollectionChangeEventArgs e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletion, Boolean changeIsInsertion, Boolean recreateNewRow, Point newCurrentCell) at System.Windows.Forms.DataGridViewRowCollection.ClearInternal(Boolean recreateNewRow) at System.Windows.Forms.DataGridView.RefreshRows(Boolean scrollIntoView) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e) at System.Data.DataView.OnListChanged(ListChangedEventArgs e) at System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action) at System.Data.Index.OnListChanged(ListChangedEventArgs e) at System.Data.DataTable.ResetInternalIndexes(DataColumn column) at System.Data.DataTable.Clear(Boolean clearAll) at MCAP.MaintenanceDataSetTableAdapters.WebsitePageDownloadTableAdapter.FillByWhereClause(WebsitePageDownloadDataTable dataTable, String whereClause) in C:\Users\mmarshall.MTMOBAY\Desktop\Mark\MCAP\DataSet\MaintenanceDataSet.Designer.vb:line 35940 at MCAP.UI.Processors.Maintenance.LoadFilteredWebsite(String filterCondition) in C:\Users\mmarshall.MTMOBAY\Desktop\Mark\MCAP\UIProcess\Maintenance.vb:line 6328 i found similar issue on microsoft site

                                L 1 Reply Last reply
                                0
                                • R Rhyde Marsh

                                  no my problem was not solved, but i it seem to be on bug on microsoft side in the control s at System.Windows.Forms.DataGridView.ComputeVisibleColumns() at System.Windows.Forms.DataGridView.LayoutScrollBars() at System.Windows.Forms.DataGridView.ComputeLayout() at System.Windows.Forms.DataGridView.PerformLayoutPrivate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl) at System.Windows.Forms.DataGridView.ResetUIState(Boolean useRowShortcut, Boolean computeVisibleRows) at System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged_PreNotification(CollectionChangeAction cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow& dataGridViewRow, Boolean changeIsInsertion) at System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged(CollectionChangeEventArgs e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletion, Boolean changeIsInsertion, Boolean recreateNewRow, Point newCurrentCell) at System.Windows.Forms.DataGridViewRowCollection.ClearInternal(Boolean recreateNewRow) at System.Windows.Forms.DataGridView.RefreshRows(Boolean scrollIntoView) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e) at System.Data.DataView.OnListChanged(ListChangedEventArgs e) at System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action) at System.Data.Index.OnListChanged(ListChangedEventArgs e) at System.Data.DataTable.ResetInternalIndexes(DataColumn column) at System.Data.DataTable.Clear(Boolean clearAll) at MCAP.MaintenanceDataSetTableAdapters.WebsitePageDownloadTableAdapter.FillByWhereClause(WebsitePageDownloadDataTable dataTable, String whereClause) in C:\Users\mmarshall.MTMOBAY\Desktop\Mark\MCAP\DataSet\MaintenanceDataSet.Designer.vb:line 35940 at MCAP.UI.Processors.Maintenance.LoadFilteredWebsite(String filterCondition) in C:\Users\mmarshall.MTMOBAY\Desktop\Mark\MCAP\UIProcess\Maintenance.vb:line 6328 i found similar issue on microsoft site

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #16

                                  That could be tested easily by giving the columns a fixed width :)

                                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                  R 1 Reply Last reply
                                  0
                                  • L Lost User

                                    That could be tested easily by giving the columns a fixed width :)

                                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                    R Offline
                                    R Offline
                                    Rhyde Marsh
                                    wrote on last edited by
                                    #17

                                    yes, but cannot be limited because the length of the url entered is unknown

                                    L 1 Reply Last reply
                                    0
                                    • R Rhyde Marsh

                                      yes, but cannot be limited because the length of the url entered is unknown

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #18

                                      This is not helping much, we're talking about different things. If you can fix the size of the column in the grid in where it is displayed to 100 pixels, then you can still enter long strings. It would prove whether or not the observed behaviour is caused by the internal resizing, or somewhere else. If fixing the width helps, then you'll need to look for other alternatives or find a fix. If fixing the width does not help, then the error is occurring somewhere else.

                                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                      R 1 Reply Last reply
                                      0
                                      • L Lost User

                                        This is not helping much, we're talking about different things. If you can fix the size of the column in the grid in where it is displayed to 100 pixels, then you can still enter long strings. It would prove whether or not the observed behaviour is caused by the internal resizing, or somewhere else. If fixing the width helps, then you'll need to look for other alternatives or find a fix. If fixing the width does not help, then the error is occurring somewhere else.

                                        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                        R Offline
                                        R Offline
                                        Rhyde Marsh
                                        wrote on last edited by
                                        #19

                                        had to change the column to accomodate a popup wasnt getting anywhere with it

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups