locked
System.Data.OracleClient is not available in aspx page RRS feed

  • Question

  • User-231641692 posted

    System.Data.OracleClient is not available in aspx page. It throws compile error.

    1. Created web application

    2. Added System.Data.OracleClient.dll in References

    3. I could write the code below in Page_Load in code behind.

    Dim a As New System.Data.OracleClient.OracleConnection

    4. But I cannot write the code inside of aspx page 

    <%
    Dim a As New System.Data.OracleClient.OracleConnection
    %>

    It gives compile error "BC30002: Type 'System.Data.OracleClient.OracleConnection' is not defined."

    What's wrong with it? Any comment will help!

    I'm using VS 2008, ASP.Net, VB.NET, Target .NET framework = 3.5

    Wednesday, September 24, 2014 2:41 PM

All replies

  • User-1715607868 posted

    This kind of depends on which version of Visual Studio you are using and what framework you are targeting.  With the latest and greatest Microsoft figured out that bogging down the server with a bunch of processing, um, bogs down the server.  Now they want everything client side with javascript, which means I need a bunch of training to catch up.  If however, you are like me and behind the curve, then you are using the previous development model and the problem you are having is that embedded VB code isn't allowed. 

    You are going to have to do everything in the code behind unless you can figure out how to do it with JQuery.  You will need to get familiar with update panels, place holders and literals.  Good luck and remember; Microsoft loves you and wants to help you maintain mental function by forcing you to constantly learn something new and different.

    Wednesday, September 24, 2014 3:32 PM
  • User-231641692 posted

    I'm using VS 2008, NET framework 3.5.

    I'm dealing with a specific situation I have to use the code.

    Wednesday, September 24, 2014 4:29 PM
  • User269602965 posted

    System.Data.OracleClient was deprecated by Microsoft

    Install OracleDataAccess.dll and Oracle Client using the ODP.NET client installation

    Then upgrade your app to .NET 4.0 for better results

    http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

    There is also a 64-bit version for 64-bit applications and operating systems

    Documentation

    http://docs.oracle.com/database/121/ODPNT/E17732-08.pdf

     

     

    Wednesday, September 24, 2014 8:39 PM
  • User-231641692 posted

    I understand it was deprecated. My real question is "Why it gives compile error?"

    I thought as long as I reference to any DLL, I could use it in aspx page with <% %> server code block as well as code behind file without 'Compile error' whether it's deprecated or not.

    Deprecation doesn't explain the compile error. I'm confused.

    Thursday, September 25, 2014 6:23 PM
  • User269602965 posted

    Deprecated, buggy, and much slower.

    However

    Dim a As New System.Data.OracleClient.OracleConnection

    I would dimension new oracle connections in the VB.NET/CS.NET code behind the ASPX page.

    Of course you can use your older System Oracle Client, but example of using Oracle.DataAccess.Client
    Creating the Oracle connection is pretty much the same for both.
    
    web.config
    
      <connectionStrings>
        <add name="OraConnStr" connectionString="Data Source={YOUR_ORACLE_SID};Persist Security Info=True;User Id={SCHEMA};Password={Password}" providerName="Oracle.DataAccess.Client">
        </add>
      </connectionStrings>
      
      <namespaces>
        <clear />
        <add namespace="Oracle.DataAccess.Client" />
        <add namespace="Oracle.DataAccess.Types" />
      </namespaces>
    
    '***********************************************'
    ' sample code behind page to update and insert data    '
    
    Imports System.Xml.Linq.XElement
    
      Public Shared Sub updateUnitsActiveFlag(ByVal decQuantity As Decimal, ByVal strDescription As String, ByVal dateDateClosed As DateTime)
        ' Insert Quantity into new row Units table'
        Dim OraConnStr As String = ConfigurationManager.ConnectionStrings("OraConnStr").ConnectionString
        Try
          Dim SQL =
          <SQL>
          INSERT INTO {YOURSCHEMANAME}.UNITS
            (UNITS_SEQ, QUANTITY, DESCRIPTION, DATE_CLOSED, DATE_TODAY) 
          VALUES 
            (UNIT_SEQ.NextVal, :BindVarQuantity, :BindVarDescription, :BindVarDateClosed, SYSDATE)
          </SQL>
          Using conn As New OracleConnection(OraConnStr)
            Using cmd As New OracleCommand(SQL.Value, conn)
              cmd.Parameters.Clear()
              cmd.Parameters.Add("BindVarQuantity", OracleDbType.Decimal, decQuantity, ParameterDirection.Input)
              cmd.Parameters.Add("BindVarDescription", OracleDbType.CLOB, strDescription, ParameterDirection.Input)
              cmd.Parameters.Add("BindVarDateClosed", OracleDbType.Date, dateDateClosed, ParameterDirection.Input)
              conn.Open()
              cmd.ExecuteNonQuery()
            End Using
          End Using
        Catch ex As Exception
          AppCalls.WriteToEventLog(ex, "Inserting UNITS.QUANTITY failed", "AppCalls.updateUnitsActiveFlag.vb")
        End Try
    End Sub
    
    Public Shared Sub updateUnitsActiveFlag(ByVal decCustomerSeq As Decimal)
      ' Update the UNITS.ACTIVE_FLAG on Customer set to Inactive'
      Dim connectionString As String = ConfigurationManager.ConnectionStrings("OraConnStr").ConnectionString
      Try
        Dim SQL =
        <SQL>
        UPDATE {YOURSCHEMANAME}.UNITS
        SET ACTIVE_FLAG        = 'Inactive',
            SEND_CONTRACT_FLAG = 'Do not send'
        WHERE CUSTOMER_SEQ = :CUSTOMER_SEQ
        </SQL>
        Using conn As New OracleConnection(connectionString)
          Using cmd As New OracleCommand(SQL.Value, conn)
            cmd.Parameters.Clear()
            cmd.Parameters.Add("CUSTOMER_SEQ", OracleDbType.Decimal, decCustomerSeq, ParameterDirection.Input)
            conn.Open()
            cmd.ExecuteNonQuery()
          End Using
        End Using
      Catch ex As Exception
        AppCalls.WriteToEventLog(ex, "Updating UNITS.ACTIVE_FLAG from customer inactivation failed", "AppCalls.updateUnitsActiveFlag.vb")
      End Try
    End Sub
    

    Friday, September 26, 2014 7:12 PM