fbpx

How ZAPtest will connect to ODBC with DSN

How ZAPtest will connect to ODBC with DSN

Home Forums Ask Expert How ZAPtest will connect to ODBC with DSN

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #32833
    Venkat M
    Participant

      Hi,

      I am unable to find the snippet of how ZapTest will connect with databses via ODBC – DNS

      Please help on this.

      Thanks,

      Regards
      Venkat

      #32843
      Sergey ZAP
      Keymaster

        Hello Venkata,
        ZAPTEST does not provide built-in utility to query a database.
        Instead you can use the ADODB object.
        This is an example for SQL Server. Please search the WEB for additional information.

        ‘create DB objects
        Set objConnection = CreateObject(“ADODB.Connection”)
        Set objRecordset = CreateObject(“ADODB.Recordset”)

        ‘This connection uses local windows authenticated user
        objConnection.Open “DRIVER={SQL Server};Server=ZAPDEMOSQL54SQL2020;Database=OLDB;Trusted_Connection=yes;”
        ‘This connection uses SQL authentication
        ‘objConnection.Open “Provider=SQLOLEDB;Data Source=ZAPDEMOSQL54SQL2020;Database=OLDB;User ID=’‘;Password=’‘;”

        ‘run query
        ContextId = 123456
        Dbquery=”SELECT TOP 1 ID FROM [Transaction] NOLOCK WHERE ContextId ='”& ContextId &”‘ ORDER BY 1 DESC”
        objRecordset.Open Dbquery,objConnection
        TransactionID = objRecordset.fields(“ID”)
        objRecordset.Close
        objConnection.Close
        set objRecordset=nothing
        set objConnection=nothing

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.

      Virtual Expert

      ZAPTEST

      ZAPTEST Logo