Results 1 to 7 of 7

Thread: MS Access Database, removing row

  1. #1

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    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:
    1. Private Sub removebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles removebtn.Click
    2.         'Remove a Company
    3.         Dim dtcmp As DataRow = m_Company.ClearRow
    4.         dtcmp("CompanyName") = companybox.Text
    5.         dtcmp("Address") = addressbox.Text
    6.         dtcmp("Phone") = phonebox.Text
    7.         dtcmp("ABN") = abnbox.Text
    8.         m_Company.Rows.Remove(dtcmp)
    9.         m_DataAdapter.Update(m_Company)
    10.         MessageBox.Show(companybox.Text & "has been deleted", _
    11.                 "Message Type: CMP SAVED", MessageBoxButtons.OK, MessageBoxIcon.Information)
    12.         m_Connection.Close()
    13.         'Add the Company Name in the List box...
    14.         clientbox.Items.Remove(companybox.Text)
    15.         Catch objException As Exception
    16.             Dim what As MsgBoxResult
    17.             what = MessageBox.Show("An Error Occurred: " & objException.Message, _
    18.             "Message Type: Error In NewCompany (fclsNewCompany)", MessageBoxButtons.OK, MessageBoxIcon.Error)
    19.         End Try
    20.     End Sub

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    Re: MS Access Database, removing row

    Quote 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?

  4. #4

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    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.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Junior Member
    Join Date
    Aug 2006
    Location
    Herts, UK
    Posts
    18

    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.
    -------

  7. #7
    Junior Member
    Join Date
    Aug 2006
    Location
    Herts, UK
    Posts
    18

    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
  •  



Click Here to Expand Forum to Full Width