Results 1 to 4 of 4

Thread: [RESOLVED] Replace DataTable with others

  1. #1

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Resolved [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
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Smile Re: Replace DataTable with others

    Quote Originally Posted by jmcilhinney View Post
    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.
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width