I recieved a mail by user(Swati) regarding database connectivity. thank you very much for suggestion...
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD="
objRecordset.CursorLocation = adUseClient
objRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source = "select field1,field2 from testTable"
ObjRecordset.ActiveConnection = ObjConnection
ObjRecordset.Open 'This will execute your Query
If ObjRecordset.recordcount>0 Then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End If
Wednesday, April 20, 2011
Tuesday, April 19, 2011
Online Services
Online Training (QTP, QTP Framework).
Online prepration of QTP Certifications.
Online Training (VB Scripting)
Sell QTP Framework.
QTP Dumps for certification.
Setup of Testing Environment for Automation Testing.
Providing candidates for Automation Testing.
Project work for Automation Testing Testing.
Project Work on contract Basis.
Please mail me for any type of services
Online prepration of QTP Certifications.
Online Training (VB Scripting)
Sell QTP Framework.
QTP Dumps for certification.
Setup of Testing Environment for Automation Testing.
Providing candidates for Automation Testing.
Project work for Automation Testing Testing.
Project Work on contract Basis.
Please mail me for any type of services
shahadat.it786@gmail.com
Thursday, April 7, 2011
How Script to write in the file and read using loop?
"Also to get the version detail of vbscript."
Dim filesys, text, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\test.txt")
text.Write "Find the last character in the text file"
text.Write " '
text.Write "Find the last character in the text fil"
text.Close
Set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
Do while readfile.AtEndOfLine <> true 'Condition to get end letter of first line'
'Do while readfile.AtEndOfStream <> true 'Condition to get end letter of file'
contents = readfile.Read(1)
'WScript.Echo contents 'Print all the letter for file'
Loop
readfile.close
'Response.Write "The last character in the text file is '" & contents & "."
WScript.Echo "The last character in the text file is '" & contents & "."
WScript.Echo ScriptEngine
WScript.Echo ScriptEngineBuildVersion
WScript.Echo ScriptEngineMajorVersion
WScript.Echo ScriptEngineMinorVersion
WScript.Echo Second(Time)
WScript.Echo Tan(55.0)
Dim filesys, text, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\test.txt")
text.Write "Find the last character in the text file"
text.Write " '
text.Write "Find the last character in the text fil"
text.Close
Set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
Do while readfile.AtEndOfLine <> true 'Condition to get end letter of first line'
'Do while readfile.AtEndOfStream <> true 'Condition to get end letter of file'
contents = readfile.Read(1)
'WScript.Echo contents 'Print all the letter for file'
Loop
readfile.close
'Response.Write "The last character in the text file is '" & contents & "."
WScript.Echo "The last character in the text file is '" & contents & "."
WScript.Echo ScriptEngine
WScript.Echo ScriptEngineBuildVersion
WScript.Echo ScriptEngineMajorVersion
WScript.Echo ScriptEngineMinorVersion
WScript.Echo Second(Time)
WScript.Echo Tan(55.0)
Script to create a instant of existing file and list out the complete information of the same
Dim filesys, demofile, createdate
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofile = filesys.GetFile("e:\TEST.xls")
createdate = demofile.DateCreated
WScript.Echo (createdate)
strHomeFolder = "E:\QTP"
Set objShell = CreateObject("Wscript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists (strHomeFolder) Then
' Assign user permission to home folder.
intRunError = objShell.Run("%COMSPEC% /c Echo Y
cacls " & strHomeFolder & " /t /c /g Administrators:F ", 2, True)
WScript.Echo (intRunError)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " & strUser & " to home folder " & strHomeFolder
Else
Wscript.Echo "In inner loop"
End If
End if
WScript.Echo (demofile.Attributes)
WScript.Echo (demofile.Type)
WScript.Echo "Date created: " & demofile.DateCreated
Wscript.Echo "Date last accessed: " & demofile.DateLastAccessed
Wscript.Echo "Date last modified: " & demofile.DateLastModified
Wscript.Echo "Drive: " & demofile.Drive
Wscript.Echo "Name: " & demofile.Name
Wscript.Echo "Parent folder: " & demofile.ParentFolder
Wscript.Echo "Path: " & demofile.Path
Wscript.Echo "Short name: " & demofile.ShortName
Wscript.Echo "Short path: " & demofile.ShortPath
Wscript.Echo "Size: " & demofile.Size
Wscript.Echo "Type: " & demofile.Type
WScript.Quit
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofile = filesys.GetFile("e:\TEST.xls")
createdate = demofile.DateCreated
WScript.Echo (createdate)
strHomeFolder = "E:\QTP"
Set objShell = CreateObject("Wscript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists (strHomeFolder) Then
' Assign user permission to home folder.
intRunError = objShell.Run("%COMSPEC% /c Echo Y
cacls " & strHomeFolder & " /t /c /g Administrators:F ", 2, True)
WScript.Echo (intRunError)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " & strUser & " to home folder " & strHomeFolder
Else
Wscript.Echo "In inner loop"
End If
End if
WScript.Echo (demofile.Attributes)
WScript.Echo (demofile.Type)
WScript.Echo "Date created: " & demofile.DateCreated
Wscript.Echo "Date last accessed: " & demofile.DateLastAccessed
Wscript.Echo "Date last modified: " & demofile.DateLastModified
Wscript.Echo "Drive: " & demofile.Drive
Wscript.Echo "Name: " & demofile.Name
Wscript.Echo "Parent folder: " & demofile.ParentFolder
Wscript.Echo "Path: " & demofile.Path
Wscript.Echo "Short name: " & demofile.ShortName
Wscript.Echo "Short path: " & demofile.ShortPath
Wscript.Echo "Size: " & demofile.Size
Wscript.Echo "Type: " & demofile.Type
WScript.Quit
How Script to search specific word from the file?
#!/usr/local/bin/perlprint ("Word to search for $ARGV[0]\n");$filecount = 1;$totalwordcount = 0;
while ($filecount <= @ARGV-1) {unless (open (INFILE, $ARGV[$filecount])){die ("Can't open input file $ARGV[$filecount]\n"); } $wordcount = 0; while ($line = ) { chop ($line); print ("Before split : $line\n"); @words = split(/ /, $line); print ("Content is : @words\n"); $w = 1; while ($w <= @words) { if ($words[$w-1] eq $ARGV[0]) { $wordcount += 1; } $w++; } } }
print ("total number of occurrences $totalwordcount\n");
while ($filecount <= @ARGV-1) {unless (open (INFILE, $ARGV[$filecount])){die ("Can't open input file $ARGV[$filecount]\n"); } $wordcount = 0; while ($line = ) { chop ($line); print ("Before split : $line\n"); @words = split(/ /, $line); print ("Content is : @words\n"); $w = 1; while ($w <= @words) { if ($words[$w-1] eq $ARGV[0]) { $wordcount += 1; } $w++; } } }
print ("total number of occurrences $totalwordcount\n");
How Script to write in a file?
#!/usr/local/bin/perl
open (MYPIPE, "cat >hello");
print MYPIPE ("Hi, Dave! Your QTP program sent this!\n");
close (MYPIPE);
open (MYPIPE, "cat >hello");
print MYPIPE ("Hi, Dave! Your QTP program sent this!\n");
close (MYPIPE);
How Script to read a file using while loop?
#!/usr/local/ActivePerl-5.8/bin/perl
if (open(MYFILE, "file1")) {
$line = ;
while ($line ne "") {
print ($line);
$line = ;
}
}
if (open(MYFILE, "file1")) {
$line = ;
while ($line ne "") {
print ($line);
$line = ;
}
}
Subscribe to:
Posts (Atom)