Performancing Metrics

Vamsi Tokala's blog: Extracting LoadRunner Error messages based on Scripts

Tuesday, December 8, 2009

Extracting LoadRunner Error messages based on Scripts

Sample C# code to fetch the LoadRunner Error messages based on Scripts using MS Access mdb file

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;

namespace LR_transaction
    public partial class Form1 : Form
        public Form1()
        static void Main()
            Application.Run(new Form1());
        private void button1_Click(object sender, EventArgs e)
            //Create the database connection 
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abc.mdb");

            //create the command object and store the sql query 
            OleDbCommand aCommand = new OleDbCommand("select [ErrorMessage].[Error Message] from ErrorMessage where [ErrorMessage].[Error Id] in(select [Error_Meter].[Error Id] from Error_Meter where [Error_Meter].[Script Id] in (select [Script].[Script ID] from Script))", aConnection);          

                //create the datareader object to connect to table 
                OleDbDataReader aReader = aCommand.ExecuteReader();
                Console.WriteLine("This is the returned data from the table");

                //Iterate throuth the database 
                while (aReader.Read())
                //close the reader 
                //close the connection Its important. 


            //Some usual exception handling
            catch (OleDbException ex)
                Console.WriteLine("Error: {0}", ex.Errors[0].Message);


No comments: