|
-
Mar 11th, 2010, 01:47 PM
#1
Thread Starter
New Member
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. 
Thanks
The Squirrel
-
Mar 11th, 2010, 07:22 PM
#2
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.
-
Mar 12th, 2010, 12:45 PM
#3
Thread Starter
New Member
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
-
Mar 12th, 2010, 07:15 PM
#4
Hyperactive Member
Re: Database work
You must call the Update method of the DataAdapter.
-
Mar 12th, 2010, 09:32 PM
#5
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|