The code from your comment is VB.Net and not C#.
"[Payroll.Payslip].Payslip" does not look like a valid table name.
You are trying to execute a script containing multiple commands. This won't work this way. You have to either send each command on it's own, or put the commands into a
BEGIN
-
END
block.
I'm not sure but this might work:
.AppendLine("BEGIN")
.AppendLine("spool D:\30Aug\Testing.txt")
.AppendLine("SELECT * FROM [Payroll.Payslip].Payslip WHERE PayslipID > 1500")
.AppendLine("spool off")
.AppendLine("END;")
Note that there are no semicolons besides that after the last command.
You should also catch exceptions to get the error message of the database engine:
Try
Catch e As OracleException
Dim errorMessage As String = "Code: " & e.Code & vbCrLf & "Message: " & e.Message
End Try
These help to identify SQL syntax errors.
[EDIT]
SPOOL
is an Oracle
SQL*Plus command. That is an Oracle database command line utility. So this command can't be used with the common programming language interfaces.
There is even no need for such an output because the interface provides all the data which would be written to the file. Just execute the query as usual and iterate over the result set. If file output is required, do that in the iteration loop.
[/EDIT]