Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database connection - TNS error
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi ,

I am getting TNS protocol error when i try to connect to Oracle database.Please any one help me to resolve this issue

I am using below code,


Code:
Public Function Action_Open_Oracle_Database_Connection(sDbHost,sDbSID,sDbUserName,sDbUserPassword,sDbProtocol,sDbPort,sQuery,FieldName)
   'Creates a DB connection object and opens the connection

                                Set  DB_CONNECTION=CreateObject("ADODB.Connection")
                               sConnection_String = "Driver={Oracle in OraClient11g_home1}; " &_
                                "CONNECTSTRING=(DESCRIPTION=" &_
                                "(ADDRESS=(PROTOCOL=" & sDbProtocol & ")"&_
                                "(HOST="& sDbHost &")(PORT=" & sDbPort & "))"&_
                                "(CONNECT_DATA=(SID=" & sDbSID & "))); uid=" & sDbUserName & ";pwd=" & sDbUserPassword & ";"

                                DB_CONNECTION.Open sConnection_String

                                'Action_Open_Oracle_Database_Connection = DB_CONNECTION

set Record_Set1=DB_CONNECTION.Execute(sQuery)
row_value1 = Record_Set1.FIELDS(FieldName)

''Rec.open sQuery ,conn
'
'UN= Rec.fields(FieldName)
msgbox row_value1
End Function


Attached Files Image(s)
   
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi
Brfore i Start to dig can u confirm that oracle client is installed on ur machine and ur able to connect to DB using client

lalit
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
I am using below and i am able to getdata from oracle.we need to have oracle installed in the machine to run this

Code:
Dim sDataSource
sDataSource = envDBInstance
Dim strConnection, oDbConn, rs, strSQL
    
strConnection = "Provider=OraOLEDB.Oracle;Data Source=" & sDataSource & ";User Id=user;Password=password;"

on Error Resume Next

    Set oDbConn = CreateObject("ADODB.Connection")
    oDbConn.Open strConnection
    
     Set oResultSet = CreateObject("ADODB.recordset")
    oResultSet.open sQuery, oDbConn, 3,3
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Connection to oracle using JDBC and QTP dileep45 0 3,468 07-30-2013, 06:39 PM
Last Post: dileep45
Question DB connection string issue jackmartins 2 6,189 07-05-2013, 02:47 PM
Last Post: Staff
  Remote Database connection through QTP PrabhatN 4 8,016 12-02-2010, 12:53 PM
Last Post: cdesserich
  mapping database user to database kamalteja 4 4,798 11-03-2010, 11:58 AM
Last Post: kamalteja
  jboss console connection debo 0 2,028 05-15-2008, 06:42 PM
Last Post: debo

Forum Jump:


Users browsing this thread: 1 Guest(s)