VBScript to Delete a Particular row in an EXCELSHEET :QTP Scripting

QTP Script to delete a specific row in an ExcelSheet.

Check This Script to get Excelsheet row count and column count in QTP

We have Excelsheet with following values

A B C
11 lak QTP
22 lax LR
33 laxmi WR
44 lakshmi QC

Set aa = CreateObject("Excel.Application")
Set bb = aa.Workbooks.Open("C:\es.xls")
Set cc = aa.worksheets("Sheet1")
cc.Rows(1).Delete
bb.Save
aa.Workbooks.Close()

Above script deletes first row of excelsheet.

After running the script excelsheet will have following values.

A B C
22 lax LR
33 laxmi WR
44 lakshmi QC

Similarly to delete 3 row(just replace 1 with 3 in the above script).

Set aa = CreateObject("Excel.Application")
Set bb = aa.Workbooks.Open("C:\es.xls")
Set cc = aa.worksheets("Sheet1")
cc.Rows(3).Delete
bb.Save
aa.Workbooks.Close()

QTP Script to export database data to excel sheet
VBScript to Check Whether Particular File Exists or Not.
Check this Post for Datatable Methods.
Excel Sheet Creation and Writing Data Into It
Data Driven Using Excel Sheet
Data Driven Using Notepad
Movie Songs Lyrics
SQL Queries Collection
Read Specific cell value from excel sheet using VBScript in QTP.

QTP Script to get column count of database table - Quick Test Professional Scripts

VBScript to get number of columns(count)present in database table.

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.


EMPNO EMPNAME EMPSAL
1 Lakshmi 30,000
2 Laxmi 25,000
3 Latha 15,000


Check This Blog For SQL Queries

Check this post for Script to get column names from database table(MS Access).


Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"d:\db.mdb"
rs.open"select*from EMP",con
column_count=rs.Fields.count
Msgbox column_count

Output:

3

SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics
QTP Script to get column names from database table(MS Access).

QTP Script to get Excelsheet Rowcount and Columncount

QTP Script To retrieve no.of columns and no.of rows in an excelsheet.


In excelsheet we have values as shown below

A B C
1 aa ll
2 bb aa
3 cc xx
4 dd mm
5 ee ii

Check This Post for Reading Specific cell value from excel sheet using VBScript in QTP

VBScript to get rowcount and columncount.

Set a= CreateObject("Excel.Application")
Set b=a.workbooks.open("d:\es.xls")
Set c=b.worksheets("Sheet1")
column_count= c.usedrange.columns.count
row_count= c.usedrange.rows.count
Msgbox "No.of Columns="&column_count
Msgbox "No.of Rows="&row_count
b.close

Result:

No.of Columns=3
No.of Rows=5

SQL Queries Collection
Movie Songs Lyrics
QTP Script to export database data to excel sheet
VBScript to Check Whether Particular File Exists or Not.
Check this Post for Datatable Methods.
Excel Sheet Creation and Writing Data Into It
Data Driven Using Excel Sheet
Data Driven Using Notepad

To Retrieve Column Names From Database Table in QTP-VBScript To Get Column Names From Table Present in Database

VB Script to get column names from database table(MS Access).

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.

EMPNO EMPNAME EMPSAL
1 Lakshmi 30,000
2 Laxmi 25,000
3 Latha 15,000

Check This Blog For SQL Queries

Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"d:\db.mdb"
rs.open"select*from EMP",con
For i = 0 To rs.Fields.Count - 1
column_name=rs.Fields(i).Name
Msgbox column_name
Next

Output:

EMPNO
EMPNAME
EMPSAL

SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge