Bindingsource not updating database

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.

Text = "Form1" ' Create an Array List containing some of the State objects.

Add(New State("Montana", "Helena")) binding Source1 = New Binding Source() ' Bind Binding Source1 to the list of states. Data Source = states ' Bind the two text boxes to properties of State.

You simply pass in the query and the command builder will use it to generate the action commands.

Someone could explain this to me or show me a example? If your query is based on a single table and you want to insert/update all the columns you retrieve back to that same table then a may be your best bet.

Add("Text", Binding Source1, "departamento") End Sub But my problem is when I have to Update the database, by adding, editing or deleting some item from Binding Source.

I'm trying to make all the connections and transactions programmatically (Data Sets, Binding Sources and so).

So I will need reopen this connection and then, somehow "read" the Data Set with the change and Update the database? You can write those yourself or, if the conditions are right, you can use a command builder to do it for you.

Because in the Module I've closed the connection to the SQL Server.

This is my first post in here, but this forum already helped me a lot. Close() Return ds Catch ex As Exception Message Box.

First, sorry for my English, i'm from Brazil and i'm trying to write without a translator.

Leave a Reply