![]() |
Clear all tables (Database, VB.NET)
In some applications, we want to delete all the data from all the tables. And in almost all cases of database development, you test the application with dummy data or enter a few dummy values for reports, etc. What happens when the database has to be taken at client's site? I have seen many people deleting the contents of each table manually!! Well, we are smart workers, this does not suit us. I have developed small code that clears all tables for me. Here is the source code for you. Please note that we will use two COM components in this application (see the beauty of interoperability):
To add the reference to these libraries, please goto Project | Add Reference | COM and select the following: Microsoft ActiveX Data Objects 2.7 Library ... The Code ... Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
_ ... Objects and Methods Used ... The objects used in the above code are:
The code is self explanatory, however, if you find any difficulty in understanding the code, please read the chapter discussing ADO in my Visual Basic COM Introduction tutorial (ADODB). However, if you still have any doubts, please feel free to contact me at rahul@coder000.com If you feel the need to discuss anything about the code or anything in the source code (as it has more contents than discussed in the above paragraphs), please do not hesitate in contacting me at http://www.coder000.com. Your feedback is welcome... :) |