I am using OPD.NET dll in a project that accesses oracle.
Users can enter any SQL code into a text field, which is then executed against db. I am trying to use OracleDataAdapter to populate a datatable using a result set, but I want to be able to return the result set in stages (for large custom queries).
An example of my problem is ...
If the select query returns 13 lines of data, the code fragment below will be executed without problems until the fourth moment oda.Fill (the initial line is 15, which does not exist) is called, I suppose, because it calls the reader who closed or something like that .
Then it throws a System.InvalidOperationException message with the message - the operation is invalid due to the current state of the object.
How do I know how many lines the command will eventually contain (so that I do not encounter an exception)?
OracleDataAdapter oda = new OracleDataAdapter(oracleCommand); oda.Requery = false; var dts = new DataTable[] { dt }; DataTable dt = new DataTable(); oda.Fill(0, 5, dts); var a = dts[0].Rows.Count; oda.Fill(a, 5, dts); var b = dts[0].Rows.Count; oda.Fill(b, 5, dts); var c = dts[0].Rows.Count; oda.Fill(c, 5, dts); var d = dts[0].Rows.Count;
Note. I briefly omitted the connection and oracle command objects for brevity.
EDIT 1: I just thought I could just wrap the SQL entered by the user in another query and execute it ... SELECT COUNT (*) FROM (... intial query here ...) but this is not a completely clean solution, and Of course, is there a method somewhere that I have not seen?
Thanks in advance.