Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to clear a bindingsource without deleting from database

How to clear a bindingsource without deleting from database

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasetutorial
7 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    desanti
    wrote on last edited by
    #1

    Hello ! I'm using vb.net 2017 and EF 6. I have a bindingsource and also datagrid that is bound to this bindingsource. I need a way to clear all the items from bindingsource to empty it , but without deleting from database. I've tried

    Bindingsource1.Datasource=Nothing.

    But , after calling this , the datagrid still have all the bindingsource items.

    L 2 Replies Last reply
    0
    • D desanti

      Hello ! I'm using vb.net 2017 and EF 6. I have a bindingsource and also datagrid that is bound to this bindingsource. I need a way to clear all the items from bindingsource to empty it , but without deleting from database. I've tried

      Bindingsource1.Datasource=Nothing.

      But , after calling this , the datagrid still have all the bindingsource items.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to call the Refresh method to repaint the grid.

      D 1 Reply Last reply
      0
      • L Lost User

        You need to call the Refresh method to repaint the grid.

        D Offline
        D Offline
        desanti
        wrote on last edited by
        #3

        I've tried also Bindingsource.Clear

        Bindingsource.Clear

        Bindingsource.Clear , this is working , but does this remove also from database ( if I call savechanges for example ?)

        L 1 Reply Last reply
        0
        • D desanti

          I've tried also Bindingsource.Clear

          Bindingsource.Clear

          Bindingsource.Clear , this is working , but does this remove also from database ( if I call savechanges for example ?)

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You should not use savechanges unless you want the database updated.

          D 1 Reply Last reply
          0
          • L Lost User

            You should not use savechanges unless you want the database updated.

            D Offline
            D Offline
            desanti
            wrote on last edited by
            #5

            ok , but Bindingsource.clear only remove items from bindingsource or also mark them for deletion from database ?

            L 1 Reply Last reply
            0
            • D desanti

              ok , but Bindingsource.clear only remove items from bindingsource or also mark them for deletion from database ?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Sorry, I don't know the answer. You could study the documentation, or write a simple test program to try it out.

              1 Reply Last reply
              0
              • D desanti

                Hello ! I'm using vb.net 2017 and EF 6. I have a bindingsource and also datagrid that is bound to this bindingsource. I need a way to clear all the items from bindingsource to empty it , but without deleting from database. I've tried

                Bindingsource1.Datasource=Nothing.

                But , after calling this , the datagrid still have all the bindingsource items.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                .DataSource = Nothing

                The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups