LoadRunner dynamic value from MySQL [need to download dll,32 or 64-bit consistent with database server]
LoadRunner is parameterized from the database to take values, but only static, for some real-time value of the data on the game over, such as to take SMS verification code, Because there is a libmysql.dll in MySQL, which provides a way to manipulate the database, so we can call this DLL connection database real-time from the database to take value
1 Action () 2 {3 4 int status; Define the state variable, 0 indicates success, non 0 indicates failure 5 int db_connection; Defines the initialization state of 6 int result; Define the query result status 7 char *server = "* * * *"; The IP address of the database 8 char *user = "Test"; User Name 9 Char *password = "123456"; Password Ten char *database = "* * * * *"; database name int port = 3306; Port int socket = NULL; int flags = 0; char** Result_set; To define a result set for a query 15 16//Database Operations Status=lr_load_dll ("E:\\vugen scripts\\libmysql.dll"); if (status!=0) {lr_error_message ("DLL file cannot be loaded"); Lr_error_message ("%s", Mysql_error (db_connection));//Print Load failure error message mysql_close (db_connection); Lr_abort (); Db_connection=mysql_init (NULL); Initializing MySQL connection 27 if (db_connection==null) {//If the link status is empty, exit Lr_abort (); Status=mysql_real_connect (db_connection,server,user,password,database,port,socket,flags);//Connect to MySQL Database 32 33//Print connection unsuccessful reason for if (status==null) {lr_error_message ("%s", Mysql_error (Db_connection)); 36 Mysql_close (db_connection); Lr_abort (); 38}39 40//Call the DLL method to execute the query statement. Status=mysql_query (Db_connection, " Select Vcode from Cb_vcode_list where telphone=180******** and is_deleted=0 "); 42 43//Print query failed because of the IF (status!=0) { Lr_error_message ("%s", Mysql_error (db_connection)); Mysql_close ( db_connection); Lr_abort (),}49 Result=mysql_use_result (db_connection);//Query data table while (Resul t_set= (char**) mysql_fetch_row (Result)) {lr_save_string (result_set[0], "Vcode"); Save the obtained data as a parameter Vcode55 lr_output_message ("Vcode is%s", lr_eval_string ("{Vcode}")); Printing Data 56 57 if (result_set==null) {//If the query result behaves empty, close and exit Lr_error_message ("No Query to Results"); Ysql_free_result (result); Mysql_close (db_connection); Lr_abort (); 62}63}64 65 Mysql_free_result (result); Release result set Mysql_close (db_connection); Close database Connection 0;69}
Transferred from: http://www.cnblogs.com/liu-ke/p/6363658.html
LoadRunner dynamic value from MySQL