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
To Retrieve Column Names From Database Table in QTP-VBScript To Get Column Names From Table Present in Database
VBScript to Get Cell Value of Particular Row and Column From ExcelSheet
How to get data from a particular row and a particular column from Excel Sheet in QTP?
Check This Post For Script To Get Cell Value of Particular Row and Column From Datatable in QTP.
QTP Script to get particular cell value from ExcelSheet in the specified row.
Below script is for retrieving 2rd row,2rd column cell value from already existing excelsheet in D drive.
In excelsheet we have values as shown below
A B C
1 aa xx
2 bb yy
3 cc zz
Script to get value "bb" from ExcelSheet is
Set a=createobject("Excel.application")
Set b=a.workbooks.open("D:\es.xls")
Set c=b.worksheets("Sheet1")
d=c.cells(2,2).value
msgbox d
b.close
Similarly to retrieve 3rd row,1column value(3)replace d=c.cells(2,2).value with
d=c.cells(3,1).value in the above script.
SQL Queries Collection
Movie Songs Lyrics
Other QTP Scripts
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
How To Check Whether Particular File and Folder Exists or Not in QTP?
QTP Script to check whether specified file and folder exist or not.
Data Driven Testing
Datatable Methods
Script to check particular text file exists or not.
Dim f1
Set f1 = CreateObject("Scripting.FileSystemObject")
If (f1.FileExists("D:\lakshmi.txt")) Then
Msgbox "file exists"
Else
Msgbox "file doesn't exist"
End If
FileExists Method:Returns True if a specified file exists,False if it does not.
Syntax:object.FileExists(filespec)
Above script checks text file("lakshmi")in D drive.
If text file is present "file exists" message is displayed else "file doesn't exist" message will be displayed.
Script to check particular folder exists or not.
Dim f1
Set f1 = CreateObject("Scripting.FileSystemObject")
If (f1.FolderExists("C:\laxmi")) Then
Msgbox "folder exists"
Else
Msgbox "folder doesn't exist"
End If
FolderExists Method:Returns True if a specified folder exists,False if it does not.
Syntax:object.FolderExists(folderspec)
Above script checks folder("laxmi")in C drive.
If folder is present "folder exists" message is displayed else "folder doesn't exist" message will be displayed.
SQL Queries Collection
Movie Songs Lyrics
How to Move a File From One Location to Another in QTP?
How to copy a file and folder from one location to other in QTP?
Export Database Data to ExcelSheet
How to Move a File From One Location to Another in QTP?
Script to copy a file and folder from one location to other in QTP
Script for moving a file from One location to Another location in QTP?
Dim f
Set f = CreateObject("Scripting.FileSystemObject")
f.MoveFile "D:\laxmi.txt", "C:\"
Msgbox "File Moved"
Above script is for moving a text file(laxmi)from D drive to C drive.
The MoveFile method takes two parameters,the source file and the destination.
Syntax:object.MoveFile (source,destination)
My Article in Ezine Articles
Data Driven Using Notepad
Script to copy a file and folder from one location to other in QTP
SQL Queries Collection
Movie Songs Lyrics
Manual Testing Faqs
How to Copy a File and Folder From One Location to Other in QTP?
Script for copying a file from One Folder to Another Folder in QTP?
Dim f
Set f = CreateObject("Scripting.FileSystemObject")
f.CopyFile "C:\lakshmi.txt", "D:\"
Msgbox "File Copied"
Above script is for copying a text file(lakshmi)from C drive to D drive.
The CopyFile method,performs the file copy operation.
The CopyFile method takes two parameters,the source file and the destination.
My Article in Ezine Articles
Data Driven Using Notepad
Script to Create Text File
Script to Delete File
Script to Copy a folder from one drive to other in QTP.
Dim f
Set f = CreateObject("Scripting.FileSystemObject")
f.CopyFolder "D:\Test2", "C:\"
Msgbox "Folder Copied"
Above script is for copying a Folder(Test2)from D drive to C drive.
The CopyFolder method,performs the folder copy operation.
The CopyFolder method takes two parameters,the source folder and the destination
QTP Script to Get Names of Subfolders in a Folder.
SQL Queries Collection
Movie Songs Lyrics
Script to Create Folder
My Article in Ezine Articles
My Article got published in Ezine Articles.
Check My First Article in EzineArticles.Com.
I WISH U ALL A VERY HAPPY AND PROSPEROUS NEW YEAR !!!
Software Testing Faqs
Data Driven Testing in QTP
Datatable Methods
QTP Script for different Controls
Script to Capture Tooltip
VBScript Functions With Examples
QTP Script to Check All Checkboxes in a Webpage
Data driven testing using datatable