Share this page

# .NET Multiple Connection Example

    namespace Script
    {
        public partial class VuserClass
        {
            public int Action()
            {
                ActionMulti();
                return 0;
            }

            private int ActionMulti()
            {
                long connId = vts_multi.connect("123.123.123.123", 8888, LoadRunner.ConnectionOptions.KeepAlive);
                string[] cols;
                string[] vals;
                bool result;
                string val;

                result = vts_multi.clear_column(connId, "City");
                lr.log_message("clear_column - " + result.ToString());

                result = vts_multi.clear_message(connId, "Address", 1);
                lr.log_message("clear_message - " + result.ToString());

                result = vts_multi.clear_row(connId, 5);
                lr.log_message("clear_row - " + result.ToString());

                var i1 = vts_multi.column_size(connId, "Region");
                lr.log_message("column_size - " + i1.ToString());

                result = vts_multi.create_column(connId, "NewColl");
                lr.log_message("create_column - " + result.ToString());

                result = vts_multi.ensure_index(connId, "CustomerID");
                lr.log_message("ensure_index - " + result.ToString());

                result = vts_multi.drop_index(connId, "CustomerID");
                lr.log_message("drop_index - " + result.ToString());

                LoadRunner.VtsErrorCode error = vts_multi.get_last_error(connId);
                lr.log_message("get_last_error - " + error.ToString());

                int increment = vts_multi.increment(connId, "EmployeeID", 2, 1);
                lr.log_message("increment - " + increment.ToString());

                val = vts_multi.query_column(connId, "CompanyName", 1);
                lr.log_message("query_column - " + val.ToString());

                vts_multi.query_row(connId, 2, out cols, out vals);
                for (int i = 0; i < cols.Length; i++)
                {
                    lr.log_message("query_row - " + cols[i] + " - " + vals[i]);
                }

                val = vts_multi.retrieve_message(connId, "ContactName");
                lr.log_message("retrieve_message - " + val.ToString());

                vals = vts_multi.retrieve_messages(connId, "PostalCode;Country", ";");
                for (int i = 0; i < vals.Length; i++)
                {
                    lr.log_message("retrieve_messages - " + vals[i]);
                }

                vts_multi.retrieve_row(connId, out cols, out vals);
                for (int i = 0; i < cols.Length; i++)
                {
                    lr.log_message("retrieve_row - " + cols[i] + " - " + vals[i]);
                }

                result = vts_multi.send_if_unique(connId, "ContactTitle", "Mess1");
                lr.log_message("send_if_unique - " + result.ToString());

                result = vts_multi.send_message(connId, "ContactTitle", "Mess2");
                lr.log_message("send_message - " + result.ToString());

                result = vts_multi.send_row(connId, "PostalCode;Country", "65098;Ukraine", ";", LoadRunner.SendRow.SameRow);
                lr.log_message("send_row - " + result.ToString());

                result = vts_multi.send_row(connId, "PostalCode;Country", "65098;Ukraine", ";", LoadRunner.SendRow.Stacked);
                lr.log_message("send_row - " + result.ToString());

                result = vts_multi.send_row(connId, "PostalCode;Country", "65098;Ukraine", ";", LoadRunner.SendRow.StackedUnique);
                lr.log_message("send_row - " + result.ToString());

                result = vts_multi.update_message(connId, "CustomerID", 7, "BLONP_CHANGED");
                lr.log_message("update_message - " + result.ToString());

                result = vts_multi.update_message_ifequals(connId, "CustomerID", 8, "BOLID_CHANGED", "BOLID");
                lr.log_message("update_message_ifequals - " + result.ToString());

                result = vts_multi.update_row(connId, "Phone;Fax", 6, "Info;FooBar", ";");
                lr.log_message("update_row - " + result.ToString());

                vts_multi.disconnect(connId);

                return 0;
            }
        }
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: