Results 1 to 5 of 5

Thread: [RESOLVED] Can't modify DataBase + Error (screenshots)

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    10

    Resolved [RESOLVED] Can't modify DataBase + Error (screenshots)

    Hello guys and girls I'm new the the whole programing thingy and I've come across an error that I can't figure out how to fix it. Here it is:
    When I try to modify a row in a database (via gridviewer and custom save button) I get this error:

    Name:  error1.jpg
Views: 146
Size:  31.8 KB

    After a quick google search I found that this would fix the problem:

    Code:
    Try this, it worked to me:
    
    Go to edit dataset with designer (you can go there from the "Data" menu then "show data sources" and "Edit dataset with designer".
    
    Right click the adapter and select "Configure". Click "Advanced options". Make sure the "Refresh the data table" is selected. Click OK and Finish.
    
    Tell me if it works. Good luck.
    
    Osama
    All good so far but when I get to the "Advanced options" the "Refresh the data table" checkbox is gray and I can't select it

    Name:  error2.jpg
Views: 122
Size:  37.9 KB

    So... how do I fix it?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,461

    Re: Can't modify DataBase + Error (screenshots)

    There's no need or point to posting a screen shot of the entire screen when all we need to see is a short error message. Not only that, in posting the entire screen, you've made the error message too small and blurry to actually read, so we don't even know what the original issue was.

    As for the Refresh check box being greyed out, does your table have an auto-generated primary key? I'm guessing not. The point of refreshing the DataTable is to retrieve that auto-generated value from the database but if there's no value to retrieve then refreshing is pointless and if there's no way to even know which column ot retrieve then it's also impossible.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    10

    Re: Can't modify DataBase + Error (screenshots)

    Noted for the screenshots. Yes There was not primary key set. I've set one and that fixed the error! BUT for some reason the checkbox is still grayed out.
    Name:  error3.jpg
Views: 36
Size:  23.6 KB

    Name:  error4.png
Views: 36
Size:  16.0 KB


    This here was the error that seting the primery key had fixed
    Name:  error5.jpg
Views: 38
Size:  24.5 KB

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,461

    Re: Can't modify DataBase + Error (screenshots)

    Are you using an Access database? If so then that is the reason that that option is disabled.

    The point of refreshing the DataTable is to retrieve any values that were auto-generated by the database. In order to do that, the InsertCommand must contain both an INSERT and a SELECT statement. The Jet and ACE OLE DB providers both lack support for multiple SQL statements in a single command, thus that option is not available.

    If you need to retrieve auto-generated IDs, e.g. you're insert parent and related child data at the same time, then you should follow the CodeBank link in my signature below and check out my thread entitled Retrieving AutoNumber Values From Access or something like that.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    10

    Re: Can't modify DataBase + Error (screenshots)

    Thank you!

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