Only when I restart the application does it get removed from the Grid View. if you are showing your table in dgv and for deleting something from that table you have a button on your win form.you chose let's say ID and click "delete" button for delting an item from db table.using namespace System; using namespace System:: Collections:: Generic; using namespace System:: Component Model; using namespace System:: Data; using namespace System:: Drawing; using namespace System:: Text; using namespace System:: Xml; using namespace System:: Windows:: Forms; using namespace System:: IO; namespace System_Windows_Forms_Update Binding int main() Imports System Imports System. Collections Class Form1 Inherits Form ' Declare the objects on the form. I'm trying to add a new row to my database using the Binding Source. Are you using Data Tables, Data Sets and Data Adapters to load your data into your application? I use the Add New() and End Edit() methonds but my changes dont saved at my database ... How can i save my changes in the database (datasourse) ?
I'm trying to make all the connections and transactions programmatically (Data Sets, Binding Sources and so).
Now, I know that normally you would just call the Update method of the dataadapter, but he passes all his database calls for the entire project through a helper class that will execute parameterized sql queries (for updates/inserts), or return a bindingsource object for displaying data. Now, I know I can access the underlying datatable though something like: But I don't know if I can get to the underlying adapter from there. Get Recs By Param method of his class is merely a wrapper that builds the parameterized query, opens a connection to the sql database, executes the query and generates/returns a bindingsource. Ins Up Del - which is simply another wrapper that builds a parameterized query, executes the passed stored proceedure and returns the success/fail state of update.
But this helper class does not expose the underlaying dataadapter. Selected Index Changed ' If this is the first time the list is rendered, it doens't seem to work properly ' This if..circumvents errors associated with the initial population If Me. The heart of his helper class is this function here: Public Shared Function Get Binding Source(By Val cmd As Sql Command) As Binding Source ' Declare the binding source Dim o BS As New Binding Source ' Create new data adapter based on the specified query Dim da Get As New Sql Data Adapter(cmd) ' Populate a new data table and bind it to the binding source Dim dt Get As New Data Table ' Set the timeout of the cmd object cmd. But, since this part of the app deals with an entire table rather than just one record, that method doesn't work.
Here is that code: also, when you press your "INSERT" or "ADD" into table button, you need to load your table again (go again through this select * from .... And, you need to do that every time you make a change to your table!!!
Caveat: this answer assumes the Data Gridview is a simple single independent one, no parent Data Gridview (related table).