Results 1 to 7 of 7

Thread: How to call Oracle stored proc from vb.net app?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    How to call Oracle stored proc from vb.net app?

    I know it is different way to call Oracle stored procedure when compared to SQL server stored proc.

    I am using currently the following format to call sql proc (BTW I am using Microsoft DATA access block )

    "calling sqlserver stored proc"

    helper = GetAdoHelper()
    sConn = GetConnectionString()
    drsql = helper.ExecuteReader(sConn, CommandType.StoredProcedure, "GetCustomers")


    "How to call Oracle stored Proc"??

    any help is greatly appreciated

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Unfortunatly the MS Data Access block was designed specifically for SQL Server and uses the SQLData objects. To use Oracle, you will either need to use the OLEDB namespace, or see if there is an Oracle-specific .NET driver.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    connecting to oracle is also possible thru data access block

    http://www.gotdotnet.com/Community/W...c-aaeb21d1f431

    but, I don't know how to use it to use stored procs in oracle .

    thanks

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Right-click on your Project... Add Reference...

    (Make sure .Net is tab shown)

    Browse to System.Data.OracleClient

    Click OK

    VB Code:
    1. Dim OrcConnection1 As New System.Data.OracleClient.OracleConnection("yourconnectionstring")
    2.         Dim OrcCommand1 As New System.Data.OracleClient.OracleCommand
    3.  
    4.  
    5.         OrcCommand1.CommandType = CommandType.StoredProcedure
    6.         OrcCommand1.CommandText = "nameofyourprocedure"
    7.         OrcCommand1.Connection = OrcConnection1
    8.  
    9.         Dim myreader As System.Data.OracleClient.OracleDataReader
    10.         myreader = OrcCommand1.ExecuteReader(CommandBehavior.CloseConnection)
    11.  
    12.         While myreader.Read
    13.             'do whatever
    14.         End While
    15.  
    16.         myreader.Close()

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    don't we have to something related to the parameters?

    I guess your code works if we are calling sqlserver but not oracle.

    nath

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    It works fine... if you wanted a parameter, simply add it:

    VB Code:
    1. OrcCommand1.Parameters.Add(New OracleParameter("@fkReadTheHElp", System.Data.OracleClient.OracleType.Int32))
    2. OrcCommand1.Parameters(0).Value = 1

    Seriously, just Use the Help ... it has all the information you need...
    Last edited by nemaroller; Jul 15th, 2004 at 05:38 PM.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    thank you sir.

    I will try .

    regards
    nath

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width