Saving data from mult tables

  • Thread starter Thread starter Uri Dimant
  • Start date Start date
U

Uri Dimant

Hello, frineds
The code below works fine on the single table.
How can I save data with this technique but on mult tables ?
Let say I ahve a view with three table join i present in a grid
After doing some updates and deletes I wouild like to save data which may
impact all three tables
For now it throws me an exeption "Dynamic sql does ot support ..... multi
tables"
Does anyone have experience how to do it? I would no like to use stored
procedure.

Dim sql As String = "SELECT pub_id,pub_name,val1 FROM Publishers_1"
Dim cn As New SqlConnection(strConn)

Dim da As New SqlDataAdapter(sql, cn)

Dim cmdBuilder As New SqlCommandBuilder(da)

da.DeleteCommand = cmdBuilder.GetDeleteCommand

da.InsertCommand = cmdBuilder.GetInsertCommand

da.UpdateCommand = cmdBuilder.GetUpdateCommand



Try

da.Update(ds, "Publishers_1")

Catch ex As Exception

MessageBox.Show(ex.Message, "tt")

End Try
 
Hi Uri,

You'll have to define an adapter for each table.
I suggest you to create them at design time.
 
Back
Top