We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

[500] [URGENT] - A - vb.net winform datagrid dataset refresh timing

ullfindsmit
ullfindsmit asked
on
Medium Priority
490 Views
Last Modified: 2011-10-03
---------------------------
Object reference not set to an instance of an object.
---------------------------
   at System.Data.DataView.GetRecord(Int32 recordIndex)

   at System.Data.DataView.IsOriginalVersion(Int32 index)

   at System.Data.DataRowView.GetColumnValue(DataColumn column)

   at System.Data.DataColumnPropertyDescriptor.GetValue(Object component)

   at System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyManager source, Int32 rowNum)

   at System.Windows.Forms.DataGridTextBoxColumn.Paint(Graphics g, Rectangle bounds, CurrencyManager source, Int32 rowNum, Brush backBrush, Brush foreBrush, Boolean alignToRight)

   at System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(Graphics g, Rectangle cellBounds, DataGridColumnStyle column, Brush backBr, Brush foreBrush, Boolean alignToRight)

   at System.Windows.Forms.DataGridRow.PaintData(Graphics g, Rectangle bounds, Int32 firstVisibleColumn, Int32 columnCount, Boolean alignToRight)

   at System.Windows.Forms.DataGridRelationshipRow.Paint(Graphics g, Rectangle bounds, Rectangle trueRowBounds, Int32 firstVisibleColumn, Int32 numVisibleColumns, Boolean alignToRight)

   at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle& boundingRect)

   at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle gridBounds)

   at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe)

   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

   at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

   at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

   at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

   at System.Windows.Forms.Application.Run(Form mainForm)

   at eBuilder.Apps.TransferManagerApp.modMain.main() in C:\VSS\TransferManager\TransferManagerApplication\modMain.vb:line 45
---------------------------
OK  
---------------------------











dvQueue = New DataView(modMain.objClsDSTMW.dsTransferManager.transferManagerFile, "fFileStatus<>'Success' and fFileStatus<>'Cancelled'", "fFilePriority ASC", DataViewRowState.CurrentRows)
        dgQueue.DataSource = dvQueue


the datagrid is bound to a dataset's datatable and teh table is updated via another thread in the process... this causes the above exception... the thread updates the dataset at times may be 100 times a second.. so hwo do I work arround this.

I heard of the beginudpate endupdate event but unsuccessfull in finding how to implement it.
also how to show only a few columns necessary and how to change their header.

thanks
-smit.

pelase help
Comment
Watch Question

Are you running the : dgQueue.DataSource = dvQueue
100 times a second ?

It could be that the a thread is trying to run the code whilst already in use by another thread.

I would try locking the statment to see if it makes any difference.

ie ....

SyncLock Me
  dvQueue = New DataView(modMain.objClsDSTMW.dsTransferManager.transferManagerFile, "fFileStatus<>'Success' and fFileStatus<>'Cancelled'", "fFilePriority ASC", DataViewRowState.CurrentRows)
  dgQueue.DataSource = dvQueue
End SyncLock

Hope it helps !

Author

Commented:
but it is not binding teh grid 100 times a second... remeber its a windows form...
does the code work if you dont do it 100 times a second?
Yes, I'm confused now as to whats running 100 times. If its not the code above what is it ?
You have a bug, its probably due to pressing teh keys in teh wrong order.
can you post the code of the thread you said you use to update the table? and in which part of your code do you call the thread, is it inside any event of the datagridview?

Author

Commented:
alrit folks.... here's teh deal..
it was because of multiple threads I started fromt he TICK.

I got rid of that... now I have another problem... I get a BIG RED X on my DG when it updates.

I'll be looking it up online, if you can find it before I do... the points are yours.... else there will be a split for the effort.

-Smit.
have you found it? post the complete code for the form, can you?

Author

Commented:
there was no real fix for the problem.
Ended up decreasing the update speed on my datagrid by slowign down the process and Decreased the number of threads.

I did use this link http://www.sturmnet.org/blog/archives/2005/03/23/red-x/ as reference for some backup...

I'll leave the question open till I'm done with the project.
If anyone can find any solution I'd greatly appreciate it

Thanks
-smit

Author

Commented:
http://www.dotnet247.com/247reference/msgs/41/205926.aspx
is the solution.

thanks for your help though
Closed, 500 points refunded.
kb
Experts Exchange Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.