Hi,
I am facing a problem while filling a datatable with a query . If I am individually running a query in oracle (Toad environment) its running fine. But when in a windows service, If I am trying to fill datable its not working.
But for other Sql statement code is working fine.
Below is the piece of code for filling datable
Protected Function ExecuteQuery(ByVal sql As String) As DataTable Dim conn As IDbConnection = Nothing Dim cmd As OracleCommand = Nothing Dim da As OracleDataAdapter = Nothing Dim table As DataTable = Nothing
Try cmd = New OracleCommand cmd.CommandText = sql
If Me.conn Is Nothing Then DAO.OpenDatabase(Me.db, conn) cmd.Connection = CType(conn, OracleConnection) Else cmd.Connection = Me.conn End If
table = New DataTable da = New OracleDataAdapter(cmd) da.SafeMapping.Add("*", GetType(String)) da.Fill(table)
Catch ex As Exception Throw ex Finally If Not da Is Nothing Then da.Dispose() End If If Not cmd Is Nothing Then cmd.Dispose() End If End Try
Return table End Function
|
| Author: Dipendra Singh 06 Nov 2009 | Member Level: Bronze | Rating:  Points: 2 |
I attached the SQL for your review.
Thank you, Dipendra
SQL.txt |