tags:

views:

81

answers:

1

For taking data from SQL Server database, I can use the code as below

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 ds dataset. How can I code the same for Oracle database? I try to code as the above, but I got the error msg. ORA-00911: Invalid character

Moreover, I'd like to use the DELETE statement also. For e.g.

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 you.

+1  A: 

In order to execute multiple DML statements by a Command object, the statements must be put in a block BEGIN ... END. For e.g.

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