garethEds Posted February 10, 2017 Posted February 10, 2017 evening, One of my pupils is writing a Visual Basic front end which manipulates an Access 2016 file (the back end). She has to use SQL for some of the manipluation. She is after some advice (I'm researching also) - she wants to delete a record so... 1. The table is displayed in a form in datagrid view. 2. She can choose a row and hit a delete button - it removes the row. She has managed to code all of this. The screen updates itself and the row is gone. Howeever - it does not delete it from the Access file and when she re-loads the whole application, the record is still there. Can anyone advise how to actually remove the record from the Access file and not simply from the data grid view? Any code would be handy. Cheers Gareth
mikeprice Posted February 10, 2017 Posted February 10, 2017 based on naff all experience of this - but plenty of experience of database 15 years ago it looks like she is not committing the changes before finishing - hence the database is rolling back the change might help in googleing an answer - but I'm talking from the viewpoint of a proper database system - which Access only pretends to be
Spl1t Posted February 13, 2017 Posted February 13, 2017 Your pupil will need to use OleDB to create a connection to the access database first - so it might be worth googling that first. Once the application is connected to the DB then it should be easy as delete * from Table1 where blah or you potentially you'll need to delete active row.
sister_annex Posted February 13, 2017 Posted February 13, 2017 Is there any chance of seeing the delete code the pupil uses?
Grazza Posted February 14, 2017 Posted February 14, 2017 (edited) I use this with SQL Server: Using conn As New SqlConnection("Data Source=;Initial Catalog=;User ID=sa;Password=") Using comm As New SqlCommand() With comm .Connection = conn .CommandText = "Delete from where " .CommandType = CommandType.Text .Parameters.AddWithValue("@Y", <"Value to look for">) End With Try conn.Open() comm.ExecuteNonQuery() MsgBox("Delete Sucessfull") Catch ex As SqlException MsgBox("ERROR") Finally conn.Close() End Try End Using End Using Just change the items in the < > to suite your needs Get back to me if you need more help. Regards Graham Edited February 14, 2017 by Grazza
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now