• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 772
  • Last Modified:

Connect to Oracle using Vbscript

I am trying to query oracle using vbscript for testing. Can anyone drop in some code? also, how will I embed this code into quick test professional, which I am using for automated testing.
0
suyoggupta
Asked:
suyoggupta
  • 2
1 Solution
 
joeposter649Commented:
Dim objConnection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword
objConnection.ConnectionTimeout = 0
objConnection.Open
0
 
hiteshgupta1Commented:
Following is a smple code which i wrote while i was learning QTp
i hope it would help u
it illustrates the


Set oXLSheet=createobject ("Excel.Application")
If isnull (oXLSheet) Then
Reporter.ReportEvent micFail ("error starting Excel")
End If

oXLSheet.visible=True
oXLSheet.workbooks.Add()
Set XLSht = oXLSheet.Sheets.Item(1)


dbconnectstring = "" Add your connection string here
Dim dbconnect, dbresults
Set dbconnect = CreateObject("ADODB.Connection")
Set dbresult = CreateObject("ADODB.Recordset")

dbconnect.Open (dbconnectstring)
Dim thissql, numrows
thissql = "select * from ...."
dbresult.Open (thissql), dbconnect

For intCount = 0 To dbresult.Fields.Count - 1
XLSht.Cells(1, intCount + 1).Value = dbresult.Fields(intCount).Name
If Not dbresult.BOF Then
dbresult.MoveFirst
End If

intRow = 1
Do Until dbresult.EOF
XLSht.Cells(intRow + 1, intCount + 1).Value = dbresult.Fields(intCount).Value
dbresult.MoveNext
intRow =intRow+1
Loop
Next

oXLSheet.ActiveWorkBook.SaveAs("C:\test.xls")
Set dbresult = nothing
dbconnect.close
Set dbconnect = nothing
0
 
suyogguptaAuthor Commented:
Thank you, this is perfect..!! Hitesh, if you get time, please have a look at my latest question n plink-vbscript also..it is very difficult..
0
 
hiteshgupta1Commented:
where is dat question??
i mean in which Topic area??
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now