[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/08/2002 at 05:27PM PDT, ID: 20334260
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

.NET class called from ASP not talking to Oracle

Asked by gadkins in .NET, Microsoft Programming

Tags: oracle, oranames, tsn

Hope someone can help.

I need to instantiate a .NET class from ASP (Not ASP.NET).  I compile the class and add it to the global assembly cache.  I then run regasm to great a type for the ASP server.createobject call to work.

Here's the problem.   It all runs perfectly on my development pc... (WinXP, Visual Studio.NET) and I get the expected iResult of 0 which means a successful connection to oracle.  But when I copy the dll and the asp files to my development server (Win2K, .NET Framework) the iResult value returned from the function call is a -1 which indicates a failure.  The dll spins up fine, calls to the dll work (and return data - that's the reason why I've got that fnTest()..  Just to check a simple function) but I have no idea why I can't connect to my oracle database.

My pc and the dev server are in the same domain, both have oranames correctly configured for the TSN NAME for be found (TNSPING works from both machines).

I've included the source code for the two files... A VB class and a ASP file.   Shout if you need more info.  I was wondering is this was a permissions problem maybe, but couldn’t spot anything obvious in the permissions.

You'll note that fnGENMessageBox calls are commented out in the class...  This is cause I haven't bothered inserting the function into this test class yet.

Thanks.


------------------START VB------------------------------

Imports System.Reflection

<Assembly: AssemblyKeyFileAttribute("M:\Microsoft Visual Basic.NET\TestSDClass\TestSDClass.snk")>

Public Class clsTestSDClass

#Region "Global Declares"
    Private oCNN As ADODB.Connection
    Private oPRM As ADODB.Parameter
    Private oCMD As ADODB.Command

    Private oSTR As ADODB.Stream
    Private iRows As Integer

    Private oRS As ADODB.Recordset

    ' Return Value Constants
    Private Const S_OK As Long = 0
    Private Const S_FAILURE As Long = -1

    Private bConnected As Boolean                                       ' Are we connected to the database

    ' Database Environment
    Public Enum clsSDEnvironmentEnum As Integer
        enumENVNotSet = 0
        enumENVDevelopment = 1
        enumENVIntegration = 2
        enumENVProduction = 3
    End Enum

    ' Property Variables
    Private mEnvironment As Integer                                     ' What database environment are we in
    Private mTNSName As String                                          ' Oracle TNS Names Identifier
    Private mSMTPServerName As String                                   ' SMTP Message Server
    Private mSMTPProfileName As String                                  ' SMTP Send Profile
    Private mEmailSupportGroup As String                                ' Email Support Group

#End Region

#Region "Property Assignments"
    Public Property EmailSupportGroup() As String
        Get
            Return mEmailSupportGroup
        End Get
        Set(ByVal Value As String)
            mEmailSupportGroup = Value
        End Set
    End Property

    Public Property Environment() As Integer
        Get
            Return mEnvironment
        End Get
        Set(ByVal Value As Integer)
            mEnvironment = Value
        End Set
    End Property

    Public Property TNSNames() As String
        Get
            Return mTNSName
        End Get
        Set(ByVal Value As String)
            mTNSName = Value
        End Set
    End Property

    Public Property SMTPServerName() As String
        Get
            Return mSMTPServerName
        End Get
        Set(ByVal Value As String)
            mSMTPServerName = Value
        End Set
    End Property

    Public Property SMTPProfileName() As String
        Get
            Return mSMTPProfileName
        End Get
        Set(ByVal Value As String)
            mSMTPProfileName = Value
        End Set
    End Property
#End Region

    Public Function fnGENConnectDatabase() As Integer

        Dim sUserID As String
        Dim sPassword As String

        On Error GoTo fnGENConnectDatabase_Error

        bConnected = False
        fnGENConnectDatabase = S_FAILURE


        ' Preprocessing validation
        If mEnvironment = clsSDEnvironmentEnum.enumENVNotSet Then
            'fnGENMessageBox("fnGENConnectDatabase: An error has occurred during startup. Please provide a Data Environment.", vbCritical + vbOKOnly)
            Exit Function
        End If

        Select Case mEnvironment
            Case clsSDEnvironmentEnum.enumENVDevelopment
                sUserID = "NOTTELLING"
                sPassword = "NOTTELLING"
            Case clsSDEnvironmentEnum.enumENVIntegration
                sUserID = "NOTTELLING"
                sPassword = "NOTTELLING"
            Case clsSDEnvironmentEnum.enumENVProduction
                sUserID = "NOTTELLING"
                sPassword = "NOTTELLING"
        End Select


        'If mTNSName = vbNullString Then
        '    'fnGENMessageBox("fnGENConnectDatabase: An error has occurred during startup. Please provide an Oracle TNS Names entry.", vbCritical + vbOKOnly)
        '    Exit Function
        'End If
        'If mSMTPServerName = vbNullString Then
        '    'fnGENMessageBox("fnGENConnectDatabase: An error has occurred during startup. Please provide an SMTP Server Name for error processing.", vbCritical + vbOKOnly)
        '    Exit Function
        'End If
        'If mSMTPProfileName = vbNullString Then
        '    'fnGENMessageBox("fnGENConnectDatabase: An error has occurred during startup. Please provide an SMTP Profile Name for error processing.", vbCritical + vbOKOnly)
        '    Exit Function
        'End If
        'If mEmailSupportGroup = vbNullString Then
        '    'fnGENMessageBox("fnGENConnectDatabase: An error has occurred during startup. Please provide a valid Email support group.", vbCritical + vbOKOnly)
        '    Exit Function
        'End If

        ' Create a new instance of our SQL Engine
        'oCNN = New OleDb.OleDbConnection()
        oCNN = New ADODB.Connection()

        oCNN.ConnectionString = "Provider=OraOLEDB.Oracle;" & _
                                "Data Source=" & mTNSName & ";" & _
                                "User ID=" & sUserID & ";" & _
                                "Password=" & sPassword & ";" & _
                                "PLSQLRSet=1;ChunkSize=65535;"
        'oCNN.ConnectionString = "Provider=sqloledb;" & _
        '                        "Data Source=" & "(local)" & ";" & _
        '                        "Initial Catalog=" & "SD" & ";" & _
        '                        "User ID=" & sUserID & ";" & _
        '                        "Password=" & sPassword & ";"


        oCNN.Open()

        If Not oCNN.State = System.Data.ConnectionState.Open Then
            'DO STUFF
        End If

        ' Set that we have connected
        bConnected = True

        ' Return that we have connected
        fnGENConnectDatabase = S_OK

        Exit Function

        GoTo fnGENConnectDatabase_Exit

fnGENConnectDatabase_Cleanup:
        oCMD = Nothing
        oPRM = Nothing
        oCNN = Nothing
        GoTo fnGENConnectDatabase_Exit

fnGENConnectDatabase_Error:
        'fnGENMessageBox("fnGENConnectDatabase: An error has occurred connecting to the database." & vbCrLf & "Oracle Error Code: " & Format(oCMD.Parameters("nErrorCode").Value) & vbCrLf & Err.Description, vbCritical + vbOKOnly)
        fnGENConnectDatabase = S_FAILURE
        GoTo fnGENConnectDatabase_Cleanup

fnGENConnectDatabase_Exit:
        Exit Function

    End Function

End Class

------------------END VB------------------------------





------------------START ASP------------------------------

<%@ Language=VBScript %>

<%

set oTestSDClass = Server.CreateObject("TestSDClass.clsTestSDClass")

response.Write ("instantiated........<br>")

sTestString = "TestString"
iStrLength = oTestSDClass.fnTest(sTestString)

response.Write ("length of """ & sTestString & """ is " & iStrLength & ".<br><p>") response.Write ("call done.<hr>")

'Try Connect
oTestSDClass.TNSNames                  = "YOURORACLESERVER"
oTestSDClass.Environment            = 1
oTestSDClass.EmailSupportGroup      = "email@yourserver.com.au"
oTestSDClass.SMTPServerName            = "YOUREXCHANGESERVER"
oTestSDClass.SMTPProfileName      = "email@yourserver.com.au"

iResult = oTestSDClass.fnGENConnectDatabase()

response.Write ("iResult: " & iResult)

%>

------------------END ASP------------------------------
[+][-]08/08/02 06:21 PM, ID: 7207905

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/08/02 09:42 PM, ID: 7208197

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/08/02 09:54 PM, ID: 7208222

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, Microsoft Programming
Tags: oracle, oranames, tsn
Sign Up Now!
Solution Provided By: anthony_glenwright
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08/09/02 01:08 AM, ID: 7208544

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/11/02 05:17 PM, ID: 7213093

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/11/02 05:31 PM, ID: 7213109

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91