Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
datatable column exist
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
hello,

i tried first to import the sheet but could not proceed..the code is,i always get failed
i have an excel with username and password and trying to check to add new column if exists add value if not add column and value...please help

Code:
'datatable.ImportSheet "C:\Documents and Settings\Administrator\Desktop\excelblank.xls",1,"Action1"
'paramcount=datatable.GetSheet("Action1").GetParameterCount
'msgbox paramcount
'For i=1 to paramcount
'    If (datatable.Value(i,"Action1")="Password") then
'        msgbox "passed"
'        else
'        msgbox "failed"
'end if
'
'Next
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Use the code below,

Code:
Dim paramcount, FindParameter

datatable.ImportSheet "C:\Documents and Settings\Administrator\Desktop\excelblank.xls",1,"Action1"
paramcount=datatable.GetSheet("Action1").GetParameterCount
msgbox paramcount
For i=1 to paramcount
    If  datatable.GetSheet("Action1").GetParameter(i).Name = "Password" Then
        datatable.Value(i,"Action1")="mypassword"
        FindParameter = "Pass"
    End If
Next
If FindParameter <> "Pass" Then
    datatable.GetSheet("Action1").AddParameter "Password","mypassword"
End If

Hope it helps.

Let me know in case if you need any help.

I will post the code for doing it in excel tomorrow.

Thanks,
Elango
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
got thru on error resume next



Code:
datatable.ImportSheet "C:\Documents and Settings\Administrator\Desktop\excelblank.xls",1,"Action1"
paramcount=datatable.GetSheet("Action1").GetParameterCount
msgbox paramcount


on error resume next
val=DataTable("Result","Action1")
If err.number<> 0 then

MsgBox "Parameter does not exist"
datatable.GetSheet("Action1").AddParameter "results","Added"
Else
Msgbox "Parameter exists"
End If


but for loop not able to proceed further....please help



Thanks Elango....got it



elango can you see the link below and please explain as what he is trying to do...

i also have a question regarding local sheet data and run time data and how to compare

https://www.learnqtp.com/forums/Thread-H...data-table



Elango,

Can you please go thru the link below and please tell me the difference and how we compare

https://www.learnqtp.com/forums/Thread-H...data-table

i imported and the data is in run time data...what is local data
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
In the post you have specified, he is retrieving a value from the application under test and updating it in the data table. He wanted to compare the value retrieved from the application with the data in the external excel sheet.

I presume that you know the difference between design time data table and run time data table in QTP. If not, google it.

What are you trying to do?

Thanks,
Elango
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Exist and Visible Are True When Objects Aren't There - Is there A Better Way? zunebuggy 3 3,146 04-24-2018, 02:12 PM
Last Post: Ankur
  Time Delay issue with Exist mv8167 11 24,801 06-19-2017, 02:56 PM
Last Post: grosorg
  [UFT] Get column name from SfwObject felino 0 3,023 12-02-2015, 04:07 PM
Last Post: felino
  AddParameter method does not add in first column of datatable alpha1 4 5,584 07-14-2015, 12:44 AM
Last Post: supputuri
  Performance Issues Using '.Exist' AndyBSG 2 3,501 12-12-2014, 03:24 PM
Last Post: AndyBSG

Forum Jump:


Users browsing this thread: 1 Guest(s)