i want to update row after union conection

code conect

  Dim cmd As OleDbCommand = New OleDbCommand("SELECT tb1_type ,tb1_price FROM tb1 UNION SELECT tb2_supp,tb2_debt FROM tb2 UNION SELECT tb3_name,tb3_price FROM tb3", con)
        con.Open()
        DataAdapter1 = New OleDbDataAdapter(cmd)
        Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(DataAdapter1)
        DataSet1 = New DataSet()
        DataAdapter1.Fill(DataSet1, "tb1,tb2,tb3")
        DataGridView1.DataSource = DataSet1
        DataGridView1.DataMember = "tb1,tb2,tb3"
        con.Close()

update not wrok

 con.Open()
        Dim Sav As New OleDb.OleDbCommand
        Sav.Connection = con
        Sav.CommandType = CommandType.Text
        Sav.CommandText = "UPDATE TB1 SET  TYPE_TB1 = or TYPE_TB2 = or TYPE_TB3 = '" & _
        stock_add.TextBox1.Text & "' ,COUN_TB1 = or ,COUN_TB2 = or ,COUN_TB3 = '" & _
        stock_add.TextBox2.Text & "' where ID_TB1 or ID_TB2 or ID_TB3 LIKE '" & _
        stock_add.Label6.Text & "'"
        Sav.ExecuteNonQuery()

          DataSet1.Clear()
        BindingSource1.EndEdit()
        DataAdapter1.Fill(DataSet1, "TB1,TB2,TB3")
        DataGridView1.Refresh()
        If con.State = ConnectionState.Open Then
            con.Close()
        End If
        MsgBox("update ok")

What does not work?

update not wrok

Generally the update will not update 3 tables at once and your syntax is wrong.
I assume that you are trying this because you don't know which of the 3 tables holds the record that you need to update.
Why don't you try to update all 3 tables in their own update?

   av.CommandText = "UPDATE TB1 SET  TYPE_TB1 = '"  & _
    stock_add.TextBox1.Text & "' ,COUN_TB1 = '" & _
            stock_add.TextBox2.Text & "' where ID_TB1 LIKE '" & _
            stock_add.Label6.Text & "' " & _
            "UPDATE TB2 SET  TYPE_TB2 = '"  & _
    stock_add.TextBox1.Text & "' ,COUN_TB2 = '" & _
            stock_add.TextBox2.Text & "' where ID_TB2 LIKE '" & _
            stock_add.Label6.Text & "' " & _
            "UPDATE TB3 SET  TYPE_TB3 = '"  & _
    stock_add.TextBox1.Text & "' ,COUN_TB3 = '" & _
            stock_add.TextBox2.Text & "' where ID_TB3 LIKE '" & _
            stock_add.Label6.Text & "'"
            Sav.ExecuteNonQuery()

If the update doesn't find a record with ID like the label6 then it won't affect anything. The question is what do you expect to happen when more than 1 table have the same ID as label6?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.