Solved

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

Posted on 2006-10-25
12
422 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
0
Comment
Question by:ullfindsmit
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 10

Expert Comment

by:Kinger247
Comment Utility
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 !
0
 
LVL 12

Author Comment

by:ullfindsmit
Comment Utility
but it is not binding teh grid 100 times a second... remeber its a windows form...
0
 
LVL 13

Expert Comment

by:newyuppie
Comment Utility
does the code work if you dont do it 100 times a second?
0
 
LVL 10

Expert Comment

by:Kinger247
Comment Utility
Yes, I'm confused now as to whats running 100 times. If its not the code above what is it ?
0
 
LVL 3

Expert Comment

by:GilesBathgate
Comment Utility
You have a bug, its probably due to pressing teh keys in teh wrong order.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 13

Expert Comment

by:newyuppie
Comment Utility
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?
0
 
LVL 12

Author Comment

by:ullfindsmit
Comment Utility
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.
0
 
LVL 13

Expert Comment

by:newyuppie
Comment Utility
have you found it? post the complete code for the form, can you?
0
 
LVL 12

Author Comment

by:ullfindsmit
Comment Utility
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
0
 
LVL 12

Author Comment

by:ullfindsmit
Comment Utility
http://www.dotnet247.com/247reference/msgs/41/205926.aspx
is the solution.

thanks for your help though
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
Comment Utility
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now