|
-
Sep 21st, 2010, 03:07 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Replace DataTable with others
Hi all,
Currently, I'm developing a project related to RFID which includes display data real time on screen. (I have a SQL Server 2005 express database. Once reader throw me a tag, I will go and pull the related information of this tag from DB and return to windows application.)
One of the windows forms will display the tag data that has been read by the RFID Reader with related information. And I use DataTable to keep this data and on my form I have one GridView which datasource is point to this DataTable. (I have 10 readers which will throw me the tags that had been read and so data will come in simultaneously)
The problem is during reading and displaying information on grid, sometimes the datatable throw me an error of "DataTable internal index is corrupted: '5'".
I found some post that said to use BeginInit, EndInit and Accept Changes.
I want to know is "Is there any solution that I can replace datatable with???"
Thanks.
scsfdev
-
Sep 21st, 2010, 03:14 AM
#2
Re: Replace DataTable with others
Are you accessing the DataTable on multiple threads simultaneously? If so then that would be your issue. You should wrap any access to the table in a SyncLock block to make sure that multiple threads don't interleave.
As for the question you asked, you can use any list. By all means you can define your own class to represent a record and then use an array or collection of that type.
-
Sep 22nd, 2010, 10:58 PM
#3
Thread Starter
Addicted Member
Re: Replace DataTable with others
 Originally Posted by jmcilhinney
Are you accessing the DataTable on multiple threads simultaneously? If so then that would be your issue. You should wrap any access to the table in a SyncLock block to make sure that multiple threads don't interleave.
As for the question you asked, you can use any list. By all means you can define your own class to represent a record and then use an array or collection of that type.
Hi Jm,
Thanks for your info.
Yes. I'm using the API that comes with the reader. It has a background threading. I don't need to do anything. I just start and it will continue reading until i stop. And while continue reading, my GUI isn't freeze. So, it must have thread inside this API.
And thanks for your info on SyncLock. At first I tried to look inside intellisense but it didn't list this 'SyncLock' in it. Only after I type the full name 'SyncLock' it changed to Blue Color text. I wonder why it didn't list in intellisense.
And after I wrap around my datatable with this 'SyncLock', the error was not happen again.
So, i can say this problem is solved.
I have another issue coming up and I will post as new.
Thanks JM.
-
Sep 22nd, 2010, 11:10 PM
#4
Re: [RESOLVED] Replace DataTable with others
SyncLock is not a type. It is a VB keyword, like Dim, Function, With, etc. Older versions of VS don't display VB keywords in Intellisense. I just had a look in VS 2010 and SyncLock was included in the Intellisesnse list, along with all other VB keywords.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|