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