I've already managed to connect with SQL Server Express 2008, using a Function ("consulta") inside a Module ("db"): Dim ad As Sql Data Adapter = New Sql Data Adapter Function consulta(By Val tabela As String, Optional opt As Boolean = False, Optional optparam As String = "") As Data Set Dim ds As New Data Set Try Dim connstring As String = "Data Source=NOTEBOOK\SQLEXPRESS; Initial Catalog=Sys Market; Persist Security Info=True; User ID=admin; Password=XXXXXX" Dim con Obj As New Sql Connection(connstring) Dim sql As String If opt = True Then sql = "SELECT * FROM " & tabela & " " & optparam Else sql = "SELECT * FROM " & tabela End If Dim cmd As Sql Command = New Sql Command(sql, con Obj) ad. Update(data, table Name) End Using End Sub Private Sub btn Save_Click(sender As Object, e As Event Args) Handles btn Save. 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) ? Now What I'm trying to do is when user do the changes in the grid those changes should be reflected in the list (in object properties) and then it should be updated in the database.When you use data-bound controls, you sometimes have to respond to changes in the data source when the data source does not raise list-changed events. Private label1 As Label Private label2 As Label Private text Box1 As Text Box Private text Box2 As Text Box Private With Events button1 As Button Private binding Source1 As Binding Source Private states As Array List Public Sub New() ' Basic form setup.
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.
I've taken over a winforms project (attached to a SQL Server database) that needs to completed quickly so am trying to work with what the other developer has rather than rewriting it all.
He has an admin form with a listview and a datagridview.
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.