473,850 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGridView locks up application

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

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(ByV al msg As String)
' Receive strings from a serial port.
CheckForIllegal CrossThreadCall s = False
Dim cnnInventory As OleDbConnection

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

'Instantiate and open the connection
cnnInventory = New
OleDbConnection (My.Settings.In ventory_managem ent_databaseCon nectionString)
cnnInventory.Op en()

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

'Instantiate and initialize the data adapter
dadInventory = New OleDbDataAdapte r("SELECT * FROM Products",
dadInventory.Se lectCommand = cmmInventory

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

'Filter the data table view
dtbInventory.De faultView.RowFi lter = "ProductIDNumbe r = '" & msg &

prodID =
CType(dtbInvent ory.DefaultView (0).Row("Produc tID").ToString , Integer)
dgvRow(0) = msg
dgvRow(1) =
dtbInventory.De faultView(0).Ro w("ProductDescr iption").ToStri ng
dgvRow(2) =
dtbInventory.De faultView(0).Ro w("ProductLocat ion").ToString
dgvRow(5) = dtbInventory.De faultView(0).Ro w("ReorderLevel ").ToString
dgvRow(6) =
dtbInventory.De faultView(0).Ro w("MinimumRequi red").ToString

'Instantiate the command datatable
cmmUnitsOnHand = New OleDbCommand("S ELECT SUM(UnitsReceiv ed) -
SUM(UnitsSold) - SUM(UnitsShrink age) AS UnitsOnHand " & _
"FROM [Inventory Transactions] WHERE (ProductID = " & prodID
& ")", cnnInventory)
dtbUnitsOnHand = New DataTable

'Instantiate and initialize the data adapter
dadUnitsOnHand = New OleDbDataAdapte r("SELECT SUM(UnitsReceiv ed) -
SUM(UnitsSold) - SUM(UnitsShrink age) AS UnitsOnHand " & _
"FROM [Inventory Transactions] WHERE (ProductID = " & prodID
& ")", cnnInventory)
dadUnitsOnHand. SelectCommand = cmmUnitsOnHand

'Fill the data table view
dadUnitsOnHand. Fill(dtbUnitsOn Hand)

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

For intCounter = 0 To dtbUnitsOnHand. DefaultView.Cou nt - 1
dgvRow(3) =
dtbUnitsOnHand. DefaultView(0). Row("UnitsOnHan d").ToString
Me.DataGridView 1.Rows.Add(dgvR ow)

cnnInventory.Cl ose()
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??

Tony K.

Jun 27 '08 #1
0 1200

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

Similar topics

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. Columns work fine, and stepping through the code clearly shows that e.g. myDataGridView.Rows.ReadOnly = true; is being called, and yet the row is definitely not read only.
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, and rebind the lstMyPersonnes to my DataGridView.dataSource, it shows the new record in the DataGridView as it should be. But when I click on a cell of that row, I suddenly got this error: "Index -1
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in lock-wait, waiting to acquire row-level X locks. The lock-waits are behind applications that have row-level X locks on different rows (honestly). Both executing and lock-waiting applications have been granted IX table locks.
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 gave it a try using the example given in
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 (DFT_MON_SORT) = ON Statement (DFT_MON_STMT) = ON Table (DFT_MON_TABLE) = ON Timestamp (DFT_MON_TIMESTAMP) = ON Unit of work ...
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 there an equivalent property for the DataGridView? I have searched, but have not found one. I would like the user to be able to see all the columns of the table on one screen - thus eliminating the need to use the horizontal scroll bar to view...
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 my.
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 port (ie. barcode scanning). It seems that everything works GREAT and processes as it was meant to be until the rows exceed the display area. I have 7 columns. The Description column is the only column with the AutoSizeMode set to Fill. The...
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 between 'minimum' and 'maximum'.\r\nParameter name: Value" Source="System.Windows.Forms" ParamName="Value" StackTrace: at System.Windows.Forms.ScrollBar.set_Value(Int32 value) at System.Windows.Forms.DataGridView.ScrollRows(Int32...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.