SQL Query to DataTable in C# Statement
Hello everyone,
I have very complex SQL querys which cannot be translated to LinQ very easily with my knowledge.
Right now I use the following code to get my job done:
My Question is:
Is it possible to use the direct Oracle Plugin in LinQPad? If so, how do I have to connect?
Thanks in advance!
Best regards,
Sebastian
I have very complex SQL querys which cannot be translated to LinQ very easily with my knowledge.
Right now I use the following code to get my job done:
DataTable Table = new DataTable(); const string Server = "Server=XXXX; User ID=XXXXXXX; Password=XXXXXX"; const string sqlQuery = "SELECT * FROM XXXX"; using (OracleConnection connection = new OracleConnection(Server)) using (OracleCommand cmd = new OracleCommand(sqlQuery, connection)) using (OracleDataAdapter results = new OracleDataAdapter(cmd)) { connection.Open(); results.Fill(Table); connection.Close(); } Table.Dump();Unfortunately OracleConnection is obsolete and won’t be supported in the future. I know I could use the Oracle Data Provider to be a bit more up to date… but:
My Question is:
Is it possible to use the direct Oracle Plugin in LinQPad? If so, how do I have to connect?
Thanks in advance!
Best regards,
Sebastian
Comments
Thanks
You can figure this out by running the following query:
this.Connection
The result is Devart.Data.Oracle.OracleConnection.
So just substitute OracleConnection with Devart.Data.Oracle.OracleConnection (or add Devart.Data.Oracle to your namespace imports).
And you don't need to create a new connection - just use this.Connection and call Open on it.