Hi shalabh

*I just only advice one thing to you* each and every QTP tester write there
code in its own way don't go to other's way follow your own

way

Your procedure is correct to export the data from database table to a excel
sheet and to

datatable as well but error occur which is happened always to each n every
QTP tester

*Highlight the step where error occur and also what is the error or give the
snap shot i will solve your problem in your way*

On Mon, Mar 21, 2011 at 10:06 PM, Shalabh Dixit <[email protected]>wrote:

> 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

-- 
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