Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. SQL working in SQLPlus but not returning rows in VB.net using Oracle.OLEDB provider

SQL working in SQLPlus but not returning rows in VB.net using Oracle.OLEDB provider

Scheduled Pinned Locked Moved Visual Basic
databaseoraclecsharphelp
8 Posts 5 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    liona
    wrote on last edited by
    #1

    I have SQL that is returning 24 rows in SQLPlus however when I run the same query in VS2010 using Provider=OraOLEDB.Oracle its doesn't return any rows. I am using a LIKE operator with to_date. Any suggestions? Is it the provider I am using the problem? See example

    select level from testTable where dTime LIKE to_date('3/27/2013','MM/DD/YYYY') and station = '019654' order by dTime

    I did try it with '%3/27/2013%'

    S Richard DeemingR B 3 Replies Last reply
    0
    • L liona

      I have SQL that is returning 24 rows in SQLPlus however when I run the same query in VS2010 using Provider=OraOLEDB.Oracle its doesn't return any rows. I am using a LIKE operator with to_date. Any suggestions? Is it the provider I am using the problem? See example

      select level from testTable where dTime LIKE to_date('3/27/2013','MM/DD/YYYY') and station = '019654' order by dTime

      I did try it with '%3/27/2013%'

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      Have you tried running the query in Oracle directly?

      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

      L 1 Reply Last reply
      0
      • S Simon_Whale

        Have you tried running the query in Oracle directly?

        Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

        L Offline
        L Offline
        liona
        wrote on last edited by
        #3

        yes and it works perfectly. I am using VS2010 if that makes a difference.

        1 Reply Last reply
        0
        • L liona

          I have SQL that is returning 24 rows in SQLPlus however when I run the same query in VS2010 using Provider=OraOLEDB.Oracle its doesn't return any rows. I am using a LIKE operator with to_date. Any suggestions? Is it the provider I am using the problem? See example

          select level from testTable where dTime LIKE to_date('3/27/2013','MM/DD/YYYY') and station = '019654' order by dTime

          I did try it with '%3/27/2013%'

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          What's the code you're using to execute the query?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          L 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            What's the code you're using to execute the query?


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            L Offline
            L Offline
            liona
            wrote on last edited by
            #5

            Dim dsFred = New DataSet
            conn = New OleDbConnection("Provider=OraOLEDB.Oracle;User ID=test;Password=testPass;Data Source=ARC")
            sql = "select level from testTable where dTime LIKE to_date('3/27/2013','MM/DD/YYYY') and station = '019654' order by dTime"
            myCommand = New OleDbDataAdapter(sql, conn)
            myCommand.Fill(dsFred, "fred")
            Dim fred As Integer = dsFred.Tables("fred").Rows.Count

            T 1 Reply Last reply
            0
            • L liona

              Dim dsFred = New DataSet
              conn = New OleDbConnection("Provider=OraOLEDB.Oracle;User ID=test;Password=testPass;Data Source=ARC")
              sql = "select level from testTable where dTime LIKE to_date('3/27/2013','MM/DD/YYYY') and station = '019654' order by dTime"
              myCommand = New OleDbDataAdapter(sql, conn)
              myCommand.Fill(dsFred, "fred")
              Dim fred As Integer = dsFred.Tables("fred").Rows.Count

              T Offline
              T Offline
              TnTinMn
              wrote on last edited by
              #6

              I notice that you are using the OleDb namespace data objects and not the OracleClient objects. Try adding a reference to System.Data.OracleClient.dll and use the OracleClient.OracleConnection, OracleClient.OracleCommand, and OracleClient.OracleDataAdapter objects.

              1 Reply Last reply
              0
              • L liona

                I have SQL that is returning 24 rows in SQLPlus however when I run the same query in VS2010 using Provider=OraOLEDB.Oracle its doesn't return any rows. I am using a LIKE operator with to_date. Any suggestions? Is it the provider I am using the problem? See example

                select level from testTable where dTime LIKE to_date('3/27/2013','MM/DD/YYYY') and station = '019654' order by dTime

                I did try it with '%3/27/2013%'

                B Offline
                B Offline
                Bernhard Hiller
                wrote on last edited by
                #7

                That's a funny Oracle feature. LIKE with a date/datetime field does not make sense, I think. But I learned that "The date column will be implicitly converted to a character string (according to nls_date_format) before the comparison" (https://forums.oracle.com/forums/thread.jspa?threadID=2132385[^]) with Oracle. Never did I expect such a nonsense. What's your requirement behind that LIKE? And I guess that the cited text shows the reason for the failure in one situation and the success in another: the nls_date_format differs.

                L 1 Reply Last reply
                0
                • B Bernhard Hiller

                  That's a funny Oracle feature. LIKE with a date/datetime field does not make sense, I think. But I learned that "The date column will be implicitly converted to a character string (according to nls_date_format) before the comparison" (https://forums.oracle.com/forums/thread.jspa?threadID=2132385[^]) with Oracle. Never did I expect such a nonsense. What's your requirement behind that LIKE? And I guess that the cited text shows the reason for the failure in one situation and the success in another: the nls_date_format differs.

                  L Offline
                  L Offline
                  liona
                  wrote on last edited by
                  #8

                  What I am trying to do is capture any records that happened that day. Where it is a datetime field there are 24 records during that time period. I can always put in qualifers for midnight to midnight however I thought the LIKE would work. I will have to try the other way I guess...

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups