Ok...This is what I do:
1. Click "Add new data source..."
2. Select "Database" and click NEXT
3. Click "New Connection...", browse to my Access.mdb file, clear username and password fields and click "Test Connection" (all is well)
4. Click OK and then NEXT
5. Click YES to copy the data file to the project's output directory
6. Click "+" next to "Tables" and place check box next to the table "tblSections" that I want as my dataset (there are four columns and four rows [records] currently in the table with one primary key [ENTRYID])
7. Leave default dataset name and click FINISH (receive error that "Some updating commands could not be generated automatically. The database returned the following error: Dynamic SQL generation for the UpdateCommande is not supported against a SelectCommand that does not return any key column information."
8. Right-click dataset and select "Preview Data..." then click PREVIEW and data displays correctly (four columns and four rows); click CLOSE
9. Right-click dataset and select "Edit DataSet with Designer"
10. Right-click "tblSectionsTableAdapter" and select "Configure"
11. The following SQL statement is currently present: "SELECT ENTRYID, [SECTION], FOLDER, STOREID FROM tblSections"
12. Click ADVANCED OPTIONS; option to "Refresh the data table" is grayed out and cannot be checked; "Generate Insert, Update and Delete statements" is checked; "Use optimistic concurrency" is checked
13. Click NEXT; "Fill a DataTable" is checked and "Method name" is "Fill"; "Return a DataTable" is checked and "Method name" is "GetData"; "Create methods to send updates directly to the databas (GenerateDBDirectMethods)" is checked
14. Click NEXT; wizard results show that Update and Delete statements are not supported agains a SelectCommand that does not return any key column information; all others have green check marks
15. Click FINISH; receive error that "An unexpected error has occurred. Error Message: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."
At this point there have been so many errors I won't even continue to creating the form etc. as I know it won't work. Can anyone tell me what has gone wrong so far in the process Do I need to add some statements to the default SQL statement that was generated Any help would be greatly appreciated.
UPDATE:
Ok. I've manually added the UPDATE and INSERT commands to my dataset but don't know if they are correct as they are not updating/adding the data to my ACC DB. Also, when I click the delete button on the form all records are deleted These are all the commands:
DELETE: DELETE FROM tblSections
INSERT: INSERT INTO tblSections (ENTRYID, [SECTION], FOLDER, STOREID) VALUES ( , , , )
SELECT: SELECT ENTRYID, [SECTION], FOLDER, STOREID FROM tblSections
UPDATE: UPDATE tblSections SET ENTRYID = ENTRYID, [SECTION] = [SECTION], FOLDER = FOLDER, STOREID = STOREID
I've never used SQL commands before so I'm sure these are way off.
On my form:
If I click DELETE for one of four records and then SAVE, close the form and reopen the form I find that all four records have been deleted from both the app and the back-end ACC DB. How do I tell it to only delete the one record that was intended to be deleted
If I edit one of four records and click SAVE, close the form and reopen the form I find that no changes have taken place in either the app or the back-end ACC DB. How do I tell it to update the changed record
If I click ADD NEW, enter data into the new record then click SAVE, close the form and reopen the form I find that the new record has been added to both the app and the back-end ACC DB (GREAT!); this is fine.
|