Qtp exports data from the database to excel
Set objexcel = Createobject ("Excel. application ")
Xlsurl = "C: \ aa.xls"
Objexcel. workbooks. Open (xlsurl)
Set sheetnew = objexcel. Sheets. Item (1) 'Save the content in the database to the sheet 1 Table in Excel.
Set conn = Createobject ("ADODB. Connection ")
Set res = Createobject ("ADODB. recordset ")
Conn. Open "provider = sqloledb.1; Password = password01 !; Persist Security info = true; user id = sa; initial catalog = pcrm2; Data Source = ws-gisgtssts-03 \ paypaltestserver"
Strsql = "select * From rolebase"
Res. Open strsql, Conn, 1, 1
Dim I
I = 1
While not res. EOF
Roleid = res ("roleid"). Value
Name1 = res ("name"). Value
Isdeleted = res ("isdeleted"). Value
Sheetnew. cells (I + 2nd). value = roleid 'starting from row in the Excel table
Sheetnew. cells (I + 1, 2). value = name1
Sheetnew. cells (I + 1, 3). value = isdeleted
I = I + 1
Res. movenext
Wend
Objexcel. activeworkbook. Save
Objexcel. Quit
Set objexcel = nothing
Res. Close
Set res = nothing
Qtp exports data from the database to the able
Set conn = CreateObject("adodb.connection")
set res = createobject("adodb.recordset")
conn.Open "Provider=SQLOLEDB.1;Password=Password01!;Persist Security Info=True;User ID=sa;Initial Catalog=PCRM2;Data Source=ws-gisgtssts-03\paypaltestserver"
strSql = "select * from RoleBase"
res.Open strSql,conn,1,1
Dim i
i = 1
While not res.EOF
roleID = res("RoleId").value
name1 = res("Name").value
IsDeleted = res("IsDeleted").value
DataTable.LocalSheet.GetParameter("RoleId").ValueByRow(i) = roleID
DataTable.LocalSheet.GetParameter("Name").ValueByRow(i) = name1
DataTable.LocalSheet.GetParameter("IsDeleted").ValueByRow(i) = IsDeleted
i = i + 1
res.MoveNext
Wend
res.Close
Set res = nothing