Micro Focus QTP (UFT) Forums
Connecting SQL Server with QTP - 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: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Connecting SQL Server with QTP (/Thread-Connecting-SQL-Server-with-QTP)



Connecting SQL Server with QTP - ritugoyal - 02-09-2010

Hi All,

Please can any body tell me the way to connect to SQL server through QTP!

Regards,
Ritu


RE: Connecting SQL Server with QTP - manabh - 02-09-2010

Hi,
Try this out

Code:
objConxn.Errors.Clear
    With objConxn
        If .State = adStateClosed Then
            .Provider = "sqloledb"
            .Properties("Data Source").Value = DB_Server
            .Properties("Initial Catalog").Value = DB_Name
            If Len(Trim(DB_UserName)) = 0 And Len(Trim(DB_Password)) = 0 Then
                .Properties("Integrated Security").Value = "SSPI"
            Else
                .Properties("User Id") = DB_UserName
                .Properties("Password") = DB_Password
            End If
            .CommandTimeout = 0
            .Open
        End If
    End With