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. how to call ORacle function in vb.net

how to call ORacle function in vb.net

Scheduled Pinned Locked Moved Visual Basic
csharporaclehelptutorial
8 Posts 3 Posters 0 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.
  • H Offline
    H Offline
    hemrk
    wrote on last edited by
    #1

    Actually i want to call oracle function which returns boolean value, from vb.net . I have one function in oracle which return boolean value..0 or 1. this function is for adding user to table. i dont have right to access direct table..so i 've to use add_user(Userid,SoftwareId,Role) function for adding a user from vb.net using Oracleclient. can anybody help me ..? Thanks Hemaxi

    C N 2 Replies Last reply
    0
    • H hemrk

      Actually i want to call oracle function which returns boolean value, from vb.net . I have one function in oracle which return boolean value..0 or 1. this function is for adding user to table. i dont have right to access direct table..so i 've to use add_user(Userid,SoftwareId,Role) function for adding a user from vb.net using Oracleclient. can anybody help me ..? Thanks Hemaxi

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      The same way as any other database, just use the specific provider classes for Oracle. You get a connection to oracle (OracleConnection?). You create a command (OracleCommand) and you give it the details of the SQL you want to run and any parameters and the connection you opened earlier. Then you call ExecuteScalar() to get your value back.


      Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      H 1 Reply Last reply
      0
      • C Colin Angus Mackay

        The same way as any other database, just use the specific provider classes for Oracle. You get a connection to oracle (OracleConnection?). You create a command (OracleCommand) and you give it the details of the SQL you want to run and any parameters and the connection you opened earlier. Then you call ExecuteScalar() to get your value back.


        Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

        H Offline
        H Offline
        hemrk
        wrote on last edited by
        #3

        it gives me an error that wrong type of arguments. If you can help me on this ..will paste my code. and the function from oracle. Thanks.. hemaxi

        C 1 Reply Last reply
        0
        • H hemrk

          it gives me an error that wrong type of arguments. If you can help me on this ..will paste my code. and the function from oracle. Thanks.. hemaxi

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          hemrk wrote:

          it gives me an error that wrong type of arguments.

          What is the "wrong type of arguments"?


          Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

          1 Reply Last reply
          0
          • H hemrk

            Actually i want to call oracle function which returns boolean value, from vb.net . I have one function in oracle which return boolean value..0 or 1. this function is for adding user to table. i dont have right to access direct table..so i 've to use add_user(Userid,SoftwareId,Role) function for adding a user from vb.net using Oracleclient. can anybody help me ..? Thanks Hemaxi

            N Offline
            N Offline
            Navi15
            wrote on last edited by
            #5

            check the datatype of the arguments which ur passing. Navin

            H 2 Replies Last reply
            0
            • N Navi15

              check the datatype of the arguments which ur passing. Navin

              H Offline
              H Offline
              hemrk
              wrote on last edited by
              #6

              Hey I think som that datatype is the problematic as my stored procedure returns Boolean Datatype. and cmd.parameters.add ("",Oracledatatype....doesnt have boolean type. I m using oracleclient . So , Probably it doesnt support Boolean data type. Below is my stored procedure parameters.. PROCEDURE Add_User_Role ( UserID IN NUMBER , SoftwareID IN NUMBER , RoleNo IN NUMBER , ReturnValue OUT BOOLEAN); my vb code is like this... With cmdUserRoleFunc .Transaction = myTrans .Connection = cnContract .CommandType = CommandType.StoredProcedure .CommandText = "Add_User_Role" End With Dim paramReturnValue As New OracleParameter() paramReturnValue.ParameterName = "@return_value" paramReturnValue.OracleType = OracleType.Int32 ' here want to use boolean but doesnt have in enumeration. paramReturnValue.Direction = ParameterDirection.Output Dim paramUserId As New OracleParameter() paramUserId.ParameterName = "@UserId" paramUserId.OracleType = OracleType.Int32 paramUserId.Direction = ParameterDirection.Input paramUserId.Value = UserId Dim paramSftwrId As New OracleParameter() paramSftwrId.ParameterName = "@SoftwareId" paramSftwrId.OracleType = OracleType.Int32 paramSftwrId.Direction = ParameterDirection.Input paramSftwrId.Value = 42 Dim paramRoleNo As New OracleParameter() paramRoleNo.ParameterName = "@RoleNo" paramRoleNo.OracleType = OracleType.Int32 paramRoleNo.Direction = ParameterDirection.Input paramRoleNo.Value = RoleNo 'cmdUserRoleFunc.Parameters.Add(paramReturnValue) cmdUserRoleFunc.Parameters.Add(paramUserId) cmdUserRoleFunc.Parameters.Add(paramSftwrId) cmdUserRoleFunc.Parameters.Add(paramRoleNo) cmdUserRoleFunc.Parameters.Add(paramReturnValue) cnContract.Open() cmdUserRoleFunc.ExecuteScalar() 'Gives me error here..that illegal variable Pls. Help me..i just wanted to get rid of this problem Thanks anyways, Hemxi

              1 Reply Last reply
              0
              • N Navi15

                check the datatype of the arguments which ur passing. Navin

                H Offline
                H Offline
                hemrk
                wrote on last edited by
                #7

                Hey I think som that datatype is the problematic as my stored procedure returns Boolean Datatype. and cmd.parameters.add ("",Oracledatatype....doesnt have boolean type. I m using oracleclient . So , Probably it doesnt support Boolean data type. Below is my stored procedure parameters.. PROCEDURE Add_User_Role ( UserID IN NUMBER , SoftwareID IN NUMBER , RoleNo IN NUMBER , ReturnValue OUT BOOLEAN); my vb code is like this... With cmdUserRoleFunc .Transaction = myTrans .Connection = cnContract .CommandType = CommandType.StoredProcedure .CommandText = "Add_User_Role" End With Dim paramReturnValue As New OracleParameter() paramReturnValue.ParameterName = "@return_value" paramReturnValue.OracleType = OracleType.Int32 ' here want to use boolean but doesnt have in enumeration. paramReturnValue.Direction = ParameterDirection.Output Dim paramUserId As New OracleParameter() paramUserId.ParameterName = "@UserId" paramUserId.OracleType = OracleType.Int32 paramUserId.Direction = ParameterDirection.Input paramUserId.Value = UserId Dim paramSftwrId As New OracleParameter() paramSftwrId.ParameterName = "@SoftwareId" paramSftwrId.OracleType = OracleType.Int32 paramSftwrId.Direction = ParameterDirection.Input paramSftwrId.Value = 42 Dim paramRoleNo As New OracleParameter() paramRoleNo.ParameterName = "@RoleNo" paramRoleNo.OracleType = OracleType.Int32 paramRoleNo.Direction = ParameterDirection.Input paramRoleNo.Value = RoleNo 'cmdUserRoleFunc.Parameters.Add(paramReturnValue) cmdUserRoleFunc.Parameters.Add(paramUserId) cmdUserRoleFunc.Parameters.Add(paramSftwrId) cmdUserRoleFunc.Parameters.Add(paramRoleNo) cmdUserRoleFunc.Parameters.Add(paramReturnValue) cnContract.Open() cmdUserRoleFunc.ExecuteScalar() 'Gives me error here..that illegal variable Pls. Help me..i just wanted to get rid of this problem Thanks anyways, hemaxi

                H 1 Reply Last reply
                0
                • H hemrk

                  Hey I think som that datatype is the problematic as my stored procedure returns Boolean Datatype. and cmd.parameters.add ("",Oracledatatype....doesnt have boolean type. I m using oracleclient . So , Probably it doesnt support Boolean data type. Below is my stored procedure parameters.. PROCEDURE Add_User_Role ( UserID IN NUMBER , SoftwareID IN NUMBER , RoleNo IN NUMBER , ReturnValue OUT BOOLEAN); my vb code is like this... With cmdUserRoleFunc .Transaction = myTrans .Connection = cnContract .CommandType = CommandType.StoredProcedure .CommandText = "Add_User_Role" End With Dim paramReturnValue As New OracleParameter() paramReturnValue.ParameterName = "@return_value" paramReturnValue.OracleType = OracleType.Int32 ' here want to use boolean but doesnt have in enumeration. paramReturnValue.Direction = ParameterDirection.Output Dim paramUserId As New OracleParameter() paramUserId.ParameterName = "@UserId" paramUserId.OracleType = OracleType.Int32 paramUserId.Direction = ParameterDirection.Input paramUserId.Value = UserId Dim paramSftwrId As New OracleParameter() paramSftwrId.ParameterName = "@SoftwareId" paramSftwrId.OracleType = OracleType.Int32 paramSftwrId.Direction = ParameterDirection.Input paramSftwrId.Value = 42 Dim paramRoleNo As New OracleParameter() paramRoleNo.ParameterName = "@RoleNo" paramRoleNo.OracleType = OracleType.Int32 paramRoleNo.Direction = ParameterDirection.Input paramRoleNo.Value = RoleNo 'cmdUserRoleFunc.Parameters.Add(paramReturnValue) cmdUserRoleFunc.Parameters.Add(paramUserId) cmdUserRoleFunc.Parameters.Add(paramSftwrId) cmdUserRoleFunc.Parameters.Add(paramRoleNo) cmdUserRoleFunc.Parameters.Add(paramReturnValue) cnContract.Open() cmdUserRoleFunc.ExecuteScalar() 'Gives me error here..that illegal variable Pls. Help me..i just wanted to get rid of this problem Thanks anyways, hemaxi

                  H Offline
                  H Offline
                  hemrk
                  wrote on last edited by
                  #8

                  HEy Thanks you all for helping me. but now its working..i changed returnvalue boolean to integer. so for sure function and stored proc both are not working when it return type is boolean in vvb.net Thanks neways hemaxi

                  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