Micro Focus QTP (UFT) Forums
Exporting QTP runtime datatable to SQL server during - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Exporting QTP runtime datatable to SQL server during (/Thread-Exporting-QTP-runtime-datatable-to-SQL-server-during)



Exporting QTP runtime datatable to SQL server during - SweetyChowdhury - 05-09-2013

Hi Team,

I am importing datatable from sql server in the global sheet, then modifying few column data.
After modification, I want to write back the changes(runtime datatable) to the same datatable in the sql server database.

Is it possible to do? If yes, can you please suggest a sample code.


RE: Exporting QTP runtime datatable to SQL server during - sria123 - 05-10-2013

Its possible. given the Update access previlages to your DB.
i dont have sample code.
bt u can do this in similar way how you caonnect to the DB and query the DB


U can write a update query and execute it.

Thanks
Sonu
Code:
Function db_connect( strSQL )
        Set o_CON =CreateObject("ADODB.Command")
        Set o_RS= CreateObject("ADODB.RecordSet")
        serverName =  Left(Environment.Value("LocalHostName"), 4)&"svr"'Inputbox("Enter the DB server Name")
        If Trim( serverName)  ="" Then
            's_ConnectionString =  "dsn=" & "yourDB"
            serverName ="yourdbserver"
            s_ConnectionString ="driver=sql server;server="& serverName  &";database=yourDB;uid=yourdbuserid;pwd=yourpassword*"
        Else
         s_ConnectionString ="driver=sql server;server="& serverName  &";database=yourDB;uid=yourdbuserid;pwd=yourpassword*"
        End If
        
        o_CON.ActiveConnection = s_ConnectionString
        o_CON.CommandText= strSQL
        Set o_RS =o_CON.Execute
        Set db_connect = o_RS
End Function