Sorry for the lack of clarity in my post. I was trying to keep it short and sweet but it looks like it ended up being more confusing. Let me try again…
I have the following code hard coded in some of my ASP pages:
If Session("AgtType") = "3" Then
rsData.Open "Select AgentID, blah blah blah..."
I now have an additional AgtType of 9 that I want the code to check for. I could just rewrite the code to:
If Session("AgtType") = "3" or Session("AgtType") = "9" Then
rsData.Open "Select AgentID, blah blah blah..."
However, I want to avoid having to hard code it so that if I have to make a change in the future I don’t need to go back to all 35 (or whatever) ASP pages and make the change. Having the ASP pages look up an SQL table would allow me to make the change in one place and save me time.
The table to be looked up is called Configuration and it has 3 columns: CfgOption, CfgCode, CfgValue. I want the ASP code to look up this table and compare AgtType to the CfgOption column where CfgValue equals ‘Sales Assistant’. If I do a select statement it yields the following:
CfgOption CfgCode CfgValue
------------------------------ ---------- ------------------------------
3 NULL Sales Assistant
9 NULL Sales Assistant
In this case it would look to to see if AgtType is equal to the CfgOption value of 3 or 9. I was wondering about how to construct the ASP code to do this lookup and comparison.
I hope this makes more sense. I have been thinking more about this and was thinking of using a flag. This is what I have so far:
<%
'Determine if Agent Type is Sales assistant
'by looking up Configuration table;
'flag set to 1 if so, 0 if not
Dim rsAgtType
Dim flAgtType
set flAgtType = 0
Set rsAgtType = Server.CreateObject("ADODB.Recordset")
rsAgtType.Open "SELECT CfgOption FROM configuration WHERE CfgValue = 'Sales Assistant'" adoCn, adOpenForwardOnly, adLockReadOnly
While not rsAgtType.EOF
If Session("AgtType") = rsAgtType("CfgOption") then
set flAgtType = 1
end if
rsAgtType.MoveNext
Wend
rsAgtType.Close
%>
Then later on in the code I have the following:
If flAgtType = 1 Then
rsData.Open "Select AgentID, blah blah blah..."
Am I on the right track or is there a better way to go about this?
Thanks a million!!
Sam