OracleDataReader Returns No Records With Nested SQL

  • Thread starter Thread starter b.pruitt
  • Start date Start date
B

b.pruitt

Hello All,

Can anyone tell why one sql statement works with the data reader but
not the other. To test, I uncomment the string I need.

Dim QueryString As String

***This string does not work
'QueryString = "SELECT * FROM print_server WHERE LS = (SELECT LS FROM
vw_turboinfo WHERE tsn = '080226086')"

***This string does work, and the result returned does exist in
print_server
'QueryString = "SELECT LS FROM vw_turboinfo WHERE tsn = '080226086'"

***This string does work
'QueryString = "SELECT * FROM print_server WHERE LS = 4042390"

Dim Command As New OracleCommand(QueryString, oraCon)
Command.CommandType = CommandType.Text

***I have copied the CommandText into TOAD for Oracle for each of the
3
***strings, and each is valid and returns the correct information.
Debug.Print(Command.CommandText)

Dim reader As OracleDataReader

Try
reader = Command.ExecuteReader
While reader.Read
Debug.Print(reader.Item(1)).ToString
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
End Try
 
Hello All,

Can anyone tell why one sql statement works with the data reader but
not the other. To test, I uncomment the string I need.

Dim QueryString As String

***This string does not work
'QueryString = "SELECT * FROM print_server WHERE LS = (SELECT LS FROM
vw_turboinfo WHERE tsn = '080226086')"

***This string does work, and the result returned does exist in
print_server
'QueryString = "SELECT LS FROM vw_turboinfo WHERE tsn = '080226086'"

***This string does work
'QueryString = "SELECT * FROM print_server WHERE LS = 4042390"

Dim Command As New OracleCommand(QueryString, oraCon)
Command.CommandType = CommandType.Text

***I have copied the CommandText into TOAD for Oracle for each of the
3
***strings, and each is valid and returns the correct information.
Debug.Print(Command.CommandText)

Dim reader As OracleDataReader

Try
     reader = Command.ExecuteReader
     While reader.Read
                    Debug.Print(reader.Item(1)).ToString
     End While
     Catch ex As Exception
                MsgBox(ex.Message)
     Finally
End Try

Ok, how silly of me. The print_server table I was accessing was a new
table. I had just created it using TOAD and populated it with data.
But I had not commited the change yet. In TAOD, the sql worked fine
because I was still in session.
 
Back
Top