Guys...

I need to export the data from database table to a excel sheet and to
datatable as well.

Request you to please provide your valuable inputs...

Below is the code I tried but didn't worked... :(

Set objDB = CreateObject("ADODB.Connection")
objDB.ConnectionString = "Provider=SQLOLEDB.1;Password=1234;Persist
Security Info=True;User ID=sa;Initial Catalog=AdventureWorks;Data
Source=SHALABHDIXIT-PC"
objDB.Open

If objDB.state=1 Then
msgbox("Connection Is Establsihed")
else
msgbox("Connection is not opened")
exittest
End If

sql_query = "select DepartmentID, Name from HumanResources.Department"

Set objResults = objDB.Execute(sql_query )

Set s=datatable.GetSheet ("Global")
Set deptID=s.addparameter("DepartmentID", " ")
Set deptName=s.addparameter("Name", " ")

Do Until objResults.EOF
DataTable.SetNextRow
deptID.value = objResults("DepartmentID")
deptName.value = objResults("Name")
msgbox deptID & " " & " "& deptName
objResults.MoveNext
Loop

DataTable.ExportSheet "E:\DATA\Test.xls"
msgbox "The file is saved in E:\DATA\Test.xls"

objResults.Close
objDB.Close

-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to