|
-
Jul 26th, 2006, 08:18 PM
#1
Thread Starter
Member
MS Access Database, removing row
So far all i have done, is copyed the ADD COMPANY code, and tried to change .addrow commands to something like .clear ... or .delrow
Is there even such a command?
How do you delete rows out of an access database?
VB Code:
Private Sub removebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles removebtn.Click
'Remove a Company
Dim dtcmp As DataRow = m_Company.ClearRow
dtcmp("CompanyName") = companybox.Text
dtcmp("Address") = addressbox.Text
dtcmp("Phone") = phonebox.Text
dtcmp("ABN") = abnbox.Text
m_Company.Rows.Remove(dtcmp)
m_DataAdapter.Update(m_Company)
MessageBox.Show(companybox.Text & "has been deleted", _
"Message Type: CMP SAVED", MessageBoxButtons.OK, MessageBoxIcon.Information)
m_Connection.Close()
'Add the Company Name in the List box...
clientbox.Items.Remove(companybox.Text)
Catch objException As Exception
Dim what As MsgBoxResult
what = MessageBox.Show("An Error Occurred: " & objException.Message, _
"Message Type: Error In NewCompany (fclsNewCompany)", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
-
Jul 26th, 2006, 08:28 PM
#2
Re: MS Access Database, removing row
Intellisense will tell you what members are available and you can use the F1 key to go to the help topic for the selected member if you need more information about it. There are numerous tutorials in my signature that address ADO.NET. The Start VB.NET tute even has an Access-specific section, although ADO.NET is basically the same no matter the data source.
-
Jul 26th, 2006, 08:33 PM
#3
Thread Starter
Member
Re: MS Access Database, removing row
 Originally Posted by jmcilhinney
Intellisense will tell you what members are available and you can use the F1 key to go to the help topic for the selected member if you need more information about it. There are numerous tutorials in my signature that address ADO.NET. The Start VB.NET tute even has an Access-specific section, although ADO.NET is basically the same no matter the data source.
What is ADO.NET? What are the benefits of using ADO.NET?
Would i have to change all my current coding to suit it?
-
Jul 26th, 2006, 08:41 PM
#4
Thread Starter
Member
Re: MS Access Database, removing row
PS: Id still like to know how to delete a row out of access, just for the sake of finishing this little program i am making, then moving onto that tutorial.
I dont like leaving things unfinished.
So if you could help me out with how to delete a row out of the access database, that woul be great.
-
Jul 26th, 2006, 09:05 PM
#5
Re: MS Access Database, removing row
Your already using ADO.NET. It is the .NET method of data access and is exposed through the System.Data namespace. This means that the System.Data.DataSet class is part of ADO.NET, as are the System.Data.DataTable and System.Data.OleDb.OleDbDataAdapter classes. The ADO.NET tutorials will show you how to delete a record from a database.
-
Aug 10th, 2006, 06:41 AM
#6
Junior Member
Re: MS Access Database, removing row
To be fair jmcilhinney, I'm finding it difficult to find a reference to actually writing data back to the database in the ADO.NET guides (1 and 2). Is it inherent in one of the actions but not actually referred to as writing to the file at that point?
I've just realised that my database isn't closed properly by me which I'm going back to now, but if it isn't a case of changes made to a datagridview are written automatically when the connection is closed could you take a look at the guides you are referring to and point me in the right direction.
Trust me, I come here a lot to find out various answers and this only the second problem I've had that I couldn't resolve myself.
-------
Tenaka
Any help requested will be regarding the use of Visual Basic 2005 Express Edition unless otherwise stated.
Gratitude for advice received will start to build up prior to any response to my posts so please respond someone lest I suffer gratitude overflow.
-------
-
Aug 10th, 2006, 06:51 AM
#7
Junior Member
Re: MS Access Database, removing row
Don't worry, got it.
Damn staple was covering the relevant lines on my printout
-------
Tenaka
Any help requested will be regarding the use of Visual Basic 2005 Express Edition unless otherwise stated.
Gratitude for advice received will start to build up prior to any response to my posts so please respond someone lest I suffer gratitude overflow.
-------
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
|