-
Database work
I am creating a project that accesses various databases and am stuck on deleting the database. I am using a Jet connection and I am able to display the database in a data grid view but I have two problems.
The first is when I click on a certain square and I want to delete this row then how am I able to do this?
The second is I want to delete the whole database with a click of a button.
Any help would be appreciated. :bigyello:
Thanks
The Squirrel
-
Re: Database work
If you want to delete a row in a DataGridView then you press the Delete button, assuming the grid is configured to allow deletions. Check the grid properties and that should be fairly obvious.
As for deleting the whole database, do you actually mean deleting all the data in the database or deleting the data file itself? Also, what type of database is it? You say that you're using Jet so I'm guessing Access, but the Jet provider supports other data sources too.
-
Re: Database work
Thanks for replying jmcilhinney.
Ah I have discovered the delete on the datagridview but it doesn't update the database. I require it to do this.
Sorry yes I am using access and I want to clear the database of all records rather than deleting the file.
Thanks again and in advance for any help that you give me.
The Squirrel
-
Re: Database work
You must call the Update method of the DataAdapter.
-
Re: Database work
You should probably follow the Database FAQ link in my signature and check out somw of the ADO.NET resources there.
If you want to delete every record in a table in a database you can simply execute a DELETE statement with no WHERE clause, so every record matches, e.g.It should be noted though, that that will not reset any AutoNumber columns. In SQL Server there is a TRUNCATE statement that will reset identity columns too. I'm not sure whether Jet SQL has an equivalent but you could check the reference to see.