473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataGridView locks up application

I have a DataGridView that I NEED to display the data that is scanned with a
barcode.

The columns are:
Product Number Description Location Units On Hand Untis Scanned
Min On Hand Max On Hand
All columns are retrieved from the database except Units Scanned. That is
calculated by the # of times the operator scans a barcode.

The code I use for filling the DataGridView is:

Private Sub ReceiveData(ByVal msg As String)
' Receive strings from a serial port.
CheckForIllegalCrossThreadCalls = False
Dim cnnInventory As OleDbConnection

Dim dgvRow(7) As String
Dim cmmInventory As OleDbCommand
Dim dadInventory As OleDbDataAdapter
Dim dtbInventory As DataTable
Dim cmmUnitsOnHand As OleDbCommand
Dim dadUnitsOnHand As OleDbDataAdapter
Dim dtbUnitsOnHand As DataTable
Dim intCounter As Integer, prodID As Integer

'Instantiate and open the connection
cnnInventory = New
OleDbConnection(My.Settings.Inventory_management_d atabaseConnectionString)
cnnInventory.Open()

'Instantiate the command datatable
cmmInventory = New OleDbCommand("SELECT * FROM Products",
cnnInventory)
dtbInventory = New DataTable()

'Instantiate and initialize the data adapter
dadInventory = New OleDbDataAdapter("SELECT * FROM Products",
cnnInventory)
dadInventory.SelectCommand = cmmInventory

'Fill the data table view
dadInventory.Fill(dtbInventory)

'Filter the data table view
dtbInventory.DefaultView.RowFilter = "ProductIDNumber = '" & msg &
"'"

prodID =
CType(dtbInventory.DefaultView(0).Row("ProductID") .ToString, Integer)
dgvRow(0) = msg
dgvRow(1) =
dtbInventory.DefaultView(0).Row("ProductDescriptio n").ToString
dgvRow(2) =
dtbInventory.DefaultView(0).Row("ProductLocation") .ToString
dgvRow(5) = dtbInventory.DefaultView(0).Row("ReorderLevel").To String
dgvRow(6) =
dtbInventory.DefaultView(0).Row("MinimumRequired") .ToString

'Instantiate the command datatable
cmmUnitsOnHand = New OleDbCommand("SELECT SUM(UnitsReceived) -
SUM(UnitsSold) - SUM(UnitsShrinkage) AS UnitsOnHand " & _
"FROM [Inventory Transactions] WHERE (ProductID = " & prodID
& ")", cnnInventory)
dtbUnitsOnHand = New DataTable

'Instantiate and initialize the data adapter
dadUnitsOnHand = New OleDbDataAdapter("SELECT SUM(UnitsReceived) -
SUM(UnitsSold) - SUM(UnitsShrinkage) AS UnitsOnHand " & _
"FROM [Inventory Transactions] WHERE (ProductID = " & prodID
& ")", cnnInventory)
dadUnitsOnHand.SelectCommand = cmmUnitsOnHand

'Fill the data table view
dadUnitsOnHand.Fill(dtbUnitsOnHand)

'Filter the data table view
'dtbUnitsOnHand.DefaultView.RowFilter = "ProductID = " & prodID

For intCounter = 0 To dtbUnitsOnHand.DefaultView.Count - 1
dgvRow(3) =
dtbUnitsOnHand.DefaultView(0).Row("UnitsOnHand").T oString
Next
Me.DataGridView1.Rows.Add(dgvRow)

cnnInventory.Close()
End Sub

For each barcode ProductIDNumber scanned, it retrieves the description,
location, unitsOnHand, minOnHand, maxOnHand.

Problems: When the # of rows exceed the amount displayed, the applications
seems to freeze. Example: I have a maximum of 20 rows that can be
displayed at once, when I have entered 21 different items or more, then try
to scroll on the vertical scroll bar, the application freezes and nothing
else happens. Sometimes the scrollbar is not even displayed but instead it
looks like a bunch of little grid cells.
I have the properties set to show the vertical scroll bar.
There is not a DataSource associated with the DataGridView.

Why does it lock up when there are more rows added than displayed??

Thanks,
Tony K.

Jun 27 '08 #1
0 1187

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ben Gracewood | last post by:
Hi I'm feeling like a total idiot at the moment. We're building an app in ..NET 2.0 beta 2, and no matter how hard I try, I can't get a DataGridView to accept ReadOnly = true on a cell or row....
0
by: DraguVaso | last post by:
Hi, I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List of a custom class0: lstMyPersonnes = New List(Of clsPersonne). When I add a new clsPersonne to lstMyPersonnes,...
0
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX 5.2.0.0. We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
1
by: shenanwei | last post by:
I have db2 v8.2.5 on AIX V5.3 with all the switches on Buffer pool (DFT_MON_BUFPOOL) = ON Lock (DFT_MON_LOCK) = ON Sort ...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
3
by: Tony K | last post by:
VB 2005 - Windows Vista I have a form that seems to lock up when the number of rows exceed the height of the datagridview. The following code executes when data is received through the serial...
4
by: alex21 | last post by:
Ok im getting this exception from a DataGridView control in my program. System.ArgumentOutOfRangeException was unhandled Message="Value of '132' is not valid for 'Value'. 'Value' should be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.