SQL select in cicode

I am trying to select a field in a sql table in cicode and write the result to a citect tag. I am using Plant Scada 2020R2. I have made the DSN called Historian



and have a cicode function called TestTankNumber which is called from a button on a test page.
The cicode is as follows.

FUNCTION TestTankVolume()

STRING sTankNumber;
INT hSQL;
STRING sName;
INT Status;
STRING sCapacity;


sTankNumber=(LargeKeyPad("Enter Front Tank Number",sTankNumber));

hSQL = SQLConnect("DSN=Historian;Uid=sql_Reports;Pwd=Citect_Reports");
IF hSQL <> -1 THEN
Status = SQLExec(hSQL, "SELECT Tank_A_Volume FROM tbl_Reception_Tanks WHERE Tank_A_Number = 'sTankNumber'");
IF Status = 0 THEN
sCapacity = SQLGetField(hSQL, "Tank_A_Volume");

SQLEnd(hSQL);
ELSE
Message("Information", SQLErrMsg(), 48);
END
SQLDisconnect(hSQL);
ELSE
Message("Information", SQLErrMsg(), 48);
END

TagWrite("Pasteuriser.Recipe_Cream_0" , sCapacity);
TagWrite("Pasteuriser.Recipe_Cream_1" , sCapacity);

RETURN 0;
END

I don't see the SELECT result and sCapacity reads "".

Any help would be great