【正文】
database. To do this first add another button the form and give it the caption Save and then create a click event procedure for the button. Then type in the following statement in the click event procedure: (DsAuthors1) This statement calls the Update method of the Data Adapter and you need to specify the dataset to update as the parameter. Now run the application again and change the surname again and then click on the Save button. Close the application and run it again and you should see the change has been made to the database now. Try adding a new row at thee bottom of the data grid using your name and make up data for the other attributes. Be careful to use the correct format for data otherwise you may get an error if the format of what you enter does not match. Don’t forget to click on 39。Ann Exciting39。DataMember39。dsAuthors139。Existing39。Test Connection Succeeded39。Data39。 tab in the tool box and then double click on the OleDbDataAdapter control to add it into the form. The Data Adapter Configuration Wizard will automatically appear to help you configure the Data Adapter. Figure 1. Location of the Data tab in the toolbox. Click on Next to move to the next screen. Now the Data connection to use box should be blank so click on the New Connection button to configure the new connection. Select the Provider tab and then select Microsoft Jet OLE DB Provider and then click on Next. In section 1 where it asks for the database to use, click on the 39。. If you don’t then check you have followed the instructions above. Click on OK to return to the Data Adapter Wizard and then click on the Next button. Make sure that Use SQL statements is selected and then click on the Next button. In the large text box type in the following SQL statement: Select * from authors Then click on the Next button and then the Finish button. You may be asked if you want to include a password in the connection string, so just click on Don’t Include Password. You should now see a new Adapter object and a new Connection object. 4. Creating the Dataset The next step is to create a Dataset class based on the query you specified above. Make sure that your Data Adapter object is selected and at the bottom of the properties pane click on the Generate Dataset… link and you should see the window below appear. Figure 3. The Generate Dataset window. Select 39。 data set and give it the name dsAuthors and make sure the 39。 added to you