How to join DML statuses at CommandText

For getting data from SQL Server database I can use below code

Dim sql As String = "SELECT emp_id, emp_name FROM emp; SELECT dep_id, dep_name FROM department;"
Dim da As New SqlClient.SqlDataAdapter(sql, connString)
Dim ds As New DataSet("Data")

da.Fill(ds)

      

I will get two tables in the ds dataset . How can I code the same for an Oracle database? I am trying to code as above, but I got an error. ORA-00911: invalid character

Also, I would like to use the DELETE statement as well. For example,

Dim sql As String = "DELETE FROM emp WHERE emp_id = 1; DELETE FROM department WHERE dep_id = 4"
Dim cmd As New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()

      

Thank.

0


source to share


1 answer


To execute multiple DML statements using a Command object, statements must be placed in a BEGIN ... END block . For example,



Dim sql As String = "BEGIN DELETE FROM emp WHERE emp_id = 1; DELETE FROM department WHERE dep_id = 4; End;"
...

      

+1


source







All Articles