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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. slow performance on 1st add new row to datatable

slow performance on 1st add new row to datatable

Scheduled Pinned Locked Moved Visual Basic
questioncsharpperformancehelp
2 Posts 2 Posters 0 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.
  • E Offline
    E Offline
    Eunice VB junior
    wrote on last edited by
    #1

    Hi Everyone, I am writing a vb.net window application. I want to add some rows into datatable. The problem I am having is when i first add a new row to the datatable, I get very slow performance (20-30 second delay). The add to datatable works but I get slow performance. Any record adds or deletes after this first add are fast. I get slow performance on the first add. I have no idea what is causing this slow performance. I cannot figure out what is delaying the add. Any thoughts on where I might be going wrong? Thanks in advanced. Here is my codes:- Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click If myTable Is Nothing Then InitGrid() Dim Row As DataRow Try For Each Row In myTable.Rows If Row.Item("HBarCode").ToString = Me.txtHBarCode.Text Then MessageBox.Show("Housing Serial Number already scanned.Duplicated.") txtHBarCode.Focus() Exit Sub End If If Row.Item("EMIBarCode").ToString = Me.txtEMIBarCode.Text Then MessageBox.Show("EMI Serial Number already scanned.Duplicated.") txtEMIBarCode.Focus() Exit Sub End If Next Row = myTable.NewRow() Me.txtCounter.Text = myTable.Rows.Count + 1 Row.Item("HBarCode") = Me.txtHBarCode.Text Row.Item("EMIBarCode") = Me.txtEMIBarCode.Text 'to check any colume without data, then only add row at myTable If Me.txtHBarCode.Text.Trim.Length = 0 Then MessageBox.Show("Please Scan in Housing BarCode.") Me.txtHBarCode.Focus() Exit Sub End If If Me.txtEMIBarCode.Text.Trim.Length = 0 Then MessageBox.Show("Please Scan in EMI BarCode.") Me.txtEMIBarCode.Focus() Exit Sub End If myTable.Rows.Add(Row) Me.txtHBarCode.Text = "" Me.txtEMIBarCode.Text = "" Me.txtHBarCode.Focus() If Me.txtCounter.Text = Me.txtQty.Text Then txtQty.Enabled = False btnComplete.Enabled = True txtHBarCode.Enabled = False txtEMIBarCode.Enabled = False End If Catch ex As Exception MessageBox.Show(ex.Message)

    D 1 Reply Last reply
    0
    • E Eunice VB junior

      Hi Everyone, I am writing a vb.net window application. I want to add some rows into datatable. The problem I am having is when i first add a new row to the datatable, I get very slow performance (20-30 second delay). The add to datatable works but I get slow performance. Any record adds or deletes after this first add are fast. I get slow performance on the first add. I have no idea what is causing this slow performance. I cannot figure out what is delaying the add. Any thoughts on where I might be going wrong? Thanks in advanced. Here is my codes:- Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click If myTable Is Nothing Then InitGrid() Dim Row As DataRow Try For Each Row In myTable.Rows If Row.Item("HBarCode").ToString = Me.txtHBarCode.Text Then MessageBox.Show("Housing Serial Number already scanned.Duplicated.") txtHBarCode.Focus() Exit Sub End If If Row.Item("EMIBarCode").ToString = Me.txtEMIBarCode.Text Then MessageBox.Show("EMI Serial Number already scanned.Duplicated.") txtEMIBarCode.Focus() Exit Sub End If Next Row = myTable.NewRow() Me.txtCounter.Text = myTable.Rows.Count + 1 Row.Item("HBarCode") = Me.txtHBarCode.Text Row.Item("EMIBarCode") = Me.txtEMIBarCode.Text 'to check any colume without data, then only add row at myTable If Me.txtHBarCode.Text.Trim.Length = 0 Then MessageBox.Show("Please Scan in Housing BarCode.") Me.txtHBarCode.Focus() Exit Sub End If If Me.txtEMIBarCode.Text.Trim.Length = 0 Then MessageBox.Show("Please Scan in EMI BarCode.") Me.txtEMIBarCode.Focus() Exit Sub End If myTable.Rows.Add(Row) Me.txtHBarCode.Text = "" Me.txtEMIBarCode.Text = "" Me.txtHBarCode.Focus() If Me.txtCounter.Text = Me.txtQty.Text Then txtQty.Enabled = False btnComplete.Enabled = True txtHBarCode.Enabled = False txtEMIBarCode.Enabled = False End If Catch ex As Exception MessageBox.Show(ex.Message)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There's nothing in the code you've posted that will do what you describe. You're going to have to step through the code in the Debugger, line-by-line, and step into all methods and functions (F11) to see on what line the code is hanging up. Set a breakpoint on the first line of the button Click event handler code and start from there.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      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