Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to write a script or database connectivity to connect oracle databse
#1
Solved: 11 Years, 4 Months ago
Hello all,

How to write a script or database connectivity to connect oracle databse, can all please help me out to connect to the oracle database and retrieve data from database.

Thanks
Reply
#2
Solved: 11 Years, 4 Months ago
hi upadhyay40,

use this piece of code to connect to your oracle database, and execute the query
Code:
Set ConObj = CreateObject("ADODB.Connection")
ConObj.Provider = "MSDAORA.1"
ConObj.Properties("Data Source").Value = YourServerName
ConObj.Properties("Initial Catalog").Value = YourDatabase
ConObj.Properties("User ID").Value = YourUserName
ConObj.Properties("Password").Value = YourPassword
ConObj.Open
If ConObj.Errors.Count = 0 Then
    Set RecObj = CreateObject("ADODB.Recordset")
    RecObj.Open YourQuery, ConObj,adLockPessimistic
End if
your results for the query will be in recordset RecObj
let me know if there is any issue.

Reply
#3
Solved: 11 Years, 4 Months ago
Hi saket,

I got error "Item cannot be found in the collection corresponding to the requested name or ordinal" on line 4

My code is

Code:
Set ConObj = CreateObject("ADODB.Connection")
ConObj.Provider = "MSDAORA.1"
ConObj.Properties("Data Source").Value = "15.5.7.13"
ConObj.Properties("Initial Catalog").Value = "sid"
ConObj.Properties("User ID").Value = "User"
ConObj.Properties("Password").Value = "Pass"
ConObj.Open
If ConObj.Errors.Count = 0 Then
    Set RecObj = CreateObject("ADODB.Recordset")
    RecObj.Open "select * from USER", ConObj,adLockPessimistic
End if
Please let me know if i make any mistake, hoping for your cooperation

Thanks
Mahesh
Reply
#4
Solved: 11 Years, 4 Months ago
I think you have provided your host ip for data source value
you should give the 'Service Name' to connect to a oracle DB

Reply
#5
Solved: 11 Years, 4 Months ago
Hi Saket,

Please correct me if i am wrong, i was given my server Ip on data source row is this ok or wrong, and can you please let me explain from where i can get Service name, please take in consider.

Thanks
Mahesh
Reply
#6
Solved: 11 Years, 4 Months ago
Server IP for data source is wrong.
In oracle, usually the database resides on a server and it uses a service name (tnsname) to connect to the DB server. the service name or the tnsname should be there on both i.e server and the client machine as well. Use NetConfiguration Assistant to create a tnsname.

let me know if you need more help on this.

Reply
#7
Solved: 11 Years, 4 Months ago
Giveing server IP and is not a Wrong one.

If you connect oracle database, the service name should be configured in the 'tnsnames.ora' file. If you need more information on this, contact any developer or DBA who is using in oracle DB
Reply
#8
Solved: 11 Years, 4 Months ago
@ v_selvam - I was never able to connect to a oracle db with providing server IP. have you tried this ever?
would you like to share how to do this?

Reply
#9
Solved: 11 Years, 4 Months ago
Hi Saket,

Sorry i was not replying, actually i had discussion with my DB admin , he said for getiing tnsname i need to install oracle client on my end, so i am installing that now, so if i will get problem i will just let you know, take in consider

Thanks
Mahesh
Reply
#10
Solved: 11 Years, 4 Months ago
@Saket - When you connect oracle database, you need the oracle service name which you configured in the 'tnsnames.ora' file.

Here is the example for oracle service name configuration

Code:
ORA_Servicename =
(DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
   )
(CONNECT_DATA =
   (SERVICE_NAME = DataBaseName)
)
)


In the above code, 'ORA_Servicename' is service name. The connecting string is given below
ConnectionString = "User Id=scott;Password=tiger;Data Source=ORA_Servicename;"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Connect to IBM MQ using UFT 12.5 soumen 2 4,574 03-17-2016, 11:16 AM
Last Post: vinod123
  DB2 Connect connection with IE 11 SRP 1 2,621 12-18-2015, 12:41 PM
Last Post: vinod123
  “Cannot connect to 8822 (connection timed out)" Ikbal 0 2,139 12-08-2014, 11:38 PM
Last Post: Ikbal
  How to write a script for fly out menus (Parent - Child - Sub Child) rajkumarsm 3 4,733 09-02-2014, 10:01 AM
Last Post: vinod123
  How to connect two web element objects? zawarepradeep@gmail.com 1 2,656 07-23-2014, 11:23 PM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 1 Guest(s)