05-20-2011, 08:25 PM
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,
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