Forum Discussion

francisco1's avatar
francisco1
New Contributor
2 years ago
Solved

How to fetch the data from a textbox

I have a keyword test in a windows application and I need fetch data from a textbox

 

for example the last textbox.

 

I need safe value on a variable to use in sql query

 

how i can do that?

thanks for your time an your response

 

  • I'm not sure whether you are doing keyword testing or scripting, but once you've captured the value from your text box, store the value into a variable to be used afterwards.

     

    Construct your sql query string, for example var sqlStr = "select * from persons where id = 100", replace the value 100 with your variable. e.g. var sqlStr = "select * from persons where id = " + myvar. Which you can then use afterwards.

     

    There are examples on how to connect to a database, see Using ADO Components.

     

     

4 Replies

  • MW_Didata's avatar
    MW_Didata
    Regular Contributor

    If you need to save a text or value from a textbox you could use:

    Set variable value: Aliases.Etc.Etc.Etc.Text or Aliases.Etc.Etc.Etc.Value.

    When using the object spy you can see what properties hold what value and just use them when setting the variable in TC. then use that variable in your query command.

    • francisco1's avatar
      francisco1
      New Contributor

      Thanks for your help, I've already seen the tutorial and I already have some tests on how to use the data driven loop for example, but in particular I need to save the value that exists in a textbox to be able to use it in a sql query and I don't understand how. Can you help me with an example or video?

      thanks for your time.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I'm not sure whether you are doing keyword testing or scripting, but once you've captured the value from your text box, store the value into a variable to be used afterwards.

     

    Construct your sql query string, for example var sqlStr = "select * from persons where id = 100", replace the value 100 with your variable. e.g. var sqlStr = "select * from persons where id = " + myvar. Which you can then use afterwards.

     

    There are examples on how to connect to a database, see Using ADO Components.