if condition (Database)in qlikview macro

    Please find the below code to validate the userid and password from Teradata in qlikview macro using if condition.

     

    sub loginform

     

     

     

     

    Set objConn = CreateObject("ADODB.Connection")

     

       

      set Name1 = ActiveDocument.Variables("vuserid")

      set Name2 = ActiveDocument.Variables("vPassword")

     

      GetUser_ID = Name1.GetContent.String

    GetPSWD = Name2.GetContent.String

     

     

    ' set f=ActiveDocument.Fields("User_ID")

    ' set f1=ActiveDocument.Fields("PSWD")

     

     

     

    'Establish a connection

    objConn.Open "PROVIDER=MSDASQL;" &  "DRIVER={Teradata};" &  "DBCName=DB name" &  "Database=database name;" & "Uid=Userid;" & "Pwd=password"

     

     

    strSQLRes ="SELECT User_ID,PSWD FROM DBname.Tablename WHERE User_ID = '"&GetUser_ID&"' and PSWD='"&GetPSWD&"'"

    Set rs = objConn.EXECUTE(strSQLRes)

     

     

    'objConn.Execute rs

     

     

    'msgbox(rs.getstring)

    If(User_ID=rs.BOF and PSWD=rs.EOF) then

    msgbox("Success...")

    Else

    msgbox("Failed...")

     

     

    end if

    end sub