Saving data from mult tables

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
 
M

Miha Markic

Hi Uri,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top