Results 1 to 4 of 4

Thread: [RESOLVED] datagridview checking records

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2007
    Posts
    694

    Resolved [RESOLVED] datagridview checking records

    datagridview dgv is populated from a datatable dt.
    Within dgv I can add records as the grid allows adding a new record.
    Before clicking on the save button, how can I check if the added records is already present in the dgv?

    Thanks

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

    Re: datagridview checking records

    How do you normally see what data is in the database? You execute a query. Same goes here. How do you specify what record to look for when you update or delete? With a WHERE clause. Same goes here. You obviously don't need the actual data, only to know whether it exists, so you can use the appropriate count function for your database. A non-zero result means that the data exists.
    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
    Fanatic Member
    Join Date
    Mar 2007
    Posts
    694

    Re: datagridview checking records

    solved by checking the rowstate.
    Thanks

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

    Re: [RESOLVED] datagridview checking records

    If that really was the solution then I must have severely misinterpreted the question. Maybe, or maybe not, you could then call the GetChanges method of the DataTable. You can specify a DataRowState and get a new Datatable containing just the rows with that state.
    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