外文翻译--visualbasic数据库连接介绍指南(编辑修改稿)内容摘要:

run it again. What happened to the change you made to the surname? You should find that the surname is still 39。 Dull39。 . The reason why, is that the change was made to the data set but not to the database. The data set is like a temporary table in the puters memory so any changes to it doesn39。 t affect the data in the actual table in the access database. You need to use the Update method of the Data Adapter to save any changes made to the dataset to the 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。 Save39。 to make the change to the database. 8. Deleting Information using the Data Grid Deleting a row from the table is also very easy. Just click in the area at the very beginning of the row before the first column to highlight the entire row. Now press the Delete key on your keyboard to delete the row and click on the Save button to save your changes to the database. In fact you don’t need to click on save after every change, just make all the changes to want to make and then click on the Save button at the very end and all changes will be saved to the database. Too Easy! 9. Filtering the Data Set Now lets try filtering the data so that we only see the data we are interested in. We will use a bo box to allow the user to enter a value for the State and then only show authors living in that state in the data grid. We will need a second data adapter to retrieve back all of the states in the database. Add another data adapter like you did for the first one and you should find that the database connection you used for the first one is already present so use that. When you type in your SQL statement, type in the following: Select distinct state from authors Then cl。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。