Qlik Community

QlikView Documents

Documents for QlikView related information.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.

if condition (Database)in qlikview macro

bindu_apte
Contributor III

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

Version history
Revision #:
1 of 1
Last update:
‎01-25-2016 07:16 AM
Updated by: