-
Junior Member
Put data in globalsheet
Set dbexample = CreateObject("ADODB.Connection")
dbexample.Open "dsn=;" & _
"uid=;" & _
"pwd=;"
'As to the query, it's also quite easy to do it:
strRequiredNameCode = DataTable.Value("strRequiredNameCode")
sql = "Select Name from ORGANIZATION where CODE='" & strRequiredNameCode & "'"
'TODO - execute your sql, etc.
set Query = dbexample.execute(sql)
Output = Query.GetString
msgbox Output
With above code, I am able to retrieve data from database and after that I would like to put my data in the globalsheet so, can anyone please tell me how can I do that?
Thanks,
Richi
-
Expert Member
Re: Put data in globalsheet
If you want to put the data into globalsheet datatable,
first of all you parameterize the column name by double clicking on the first column(A),
then type the following line at the end of your script.
datatable(1,1)=output
-
Junior Member
Re: Put data in globalsheet
Rajaputra,
Thanks for your answer. It is very useful. Can you please tell me if I want to add my output value in the Global sheet or local sheet instead of run-time data table how can I do this?
Richi
-
Expert Member
Re: Put data in globalsheet
Dear Richi,
How it is possible.
When you execute your script, then only the output value will be captured.
Without running how can you add the output value into the datatable.
-
Junior Member
Re: Put data in globalsheet
rajaputra,
I understand what you mean. Thanks for your reply! Could you please tell me after running the scripts how can you export data in the excel file or text file from run time data table. I hope you understand my question.
Richi
-
Expert Member
Re: Put data in globalsheet
You can do this by using datatable.export method
For your reference please see the below DP for Importing datata from datatable and exporting the datatable into Excel file.
systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").set "rajaputra"
Dialog("text:=Login").WinEdit("attached text:=Password:").set "mercury"
Dialog("text:=Login").WinButton("text:=OK").click
Window("text:=Flight Reservation").Activate
datatable.Importsheet "c:/1.xls",1,1
rowcount=datatable.GetRowCount
'msgbox rowcount
For i=1 to rowcount
Window("text:=Flight Reservation").WinButton("window id:=5").click
Dialog("text:=Open Order").Activate
Dialog("text:=Open Order").WinCheckBox("text:=&Order No.").set "ON"
datatable.SetCurrentRow(i)
n=datatable(1,1)
Dialog("text:=Open Order").WinEdit("window id:=1016").set n
Dialog("text:=Open Order").WinButton("text:=OK").click
If(window("text:=Flight Reservation").Dialog("text:=Open Order").Dialog("text:=Flight Reservations").exist)then
window("text:=Flight Reservation").Dialog("text:=Open Order").Dialog("text:=Flight Reservations").WinButton("text:=OK").click
window("text:=Flight Reservation").Dialog("text:=Open Order").WinButton("text:=Cancel").click
datatable(2,1)="Not Exist"
Else
datatable(2,1)="Exist"
end if
Next
DataTable.Export ("C:\flights.xls")
Window("text:=Flight Reservation").Close
Before running this script, in "1.xls" you have to put two columns.
one is OrderNo and other one is Result.
In OrderNo You can enter any valid or invalid orderno's and Result you can leave as it is.(We will output the data into Results)
-
Junior Member
Re: Put data in globalsheet
Hey,
Thanks for quick response. Can you tell me how can I export my dataTable in a specific datasheet? Let me give you more details. Let say, I have an excel file with 3 worksheet and two of the worksheet have values and one is empty so I want to export my qtp datatable in the empty worksheet how can I do this?
Thanks again for your help!
Richi
-
Junior Member
Re: Put data in globalsheet
Hi,
Use below code to put data into datatable.
DataTable("usernamel" , Global) ="hello"
Regards,
Prashanth.N
-
Expert Member
Re: Put data in globalsheet
you can do this by using exportsheet method.
for example,,
end of the script you write below statament.
datatable.exportsheet "c:\flight.xls",1
Note: as you spesified the file flight.xls should have 2 worksheets with values and worksheet names. Then only it will export into 3rd sheet.
Note: we can export particular sheet of the runtime datatable into excel file only at last sheet........
i hope you got it.
Last edited by rajaputra; 12-06-2007 at 01:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules