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

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge