Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Function based on Recordset Value

Status
Not open for further replies.

thankgodfortektips

Programmer
Dec 20, 2005
95
0
0
KY
Hi All,

I have a recordset which I am calling which will return some data, but will also return the name of a function that will need to be run, depending on the data retreived from the DB.
So Table1
FieldID FunctionName
1 FillDescription1()
2 FillDescription2()
3 FillDescription1()
4 FillDescription3()

So the problem I am having is that I have all the data there, but I cant call the function based of the FunctionName value. I am assuming it is because the ASP code is returning a char value, but I need to use that to then call a function.

Does anyone know how to do this?

Thanks in advance!
 
[1] This is one-liner but it is unsafe and could make your system losing control of the outcome because the value may be "subversively" storing complete malicious functional blocks.
[tt] execute(rs("FunctionName").value)[/tt]

[2] This would be much more safer but you've to enumerate all the functions scripted or included.
[tt]
select case rs("FunctionName").value
case "FillDescription1()"
FillDescription1()
case "FillDescription2()"
FillDescription2()
case "FillDescription3()"
FillDescription3()
case else
'do nothing or issue a warning
end select
[/tt]
 
Thanks tsuji... Funnily enough I figured out the select at around 1am last night...

I am the person who is putting the function names in the table so the execute(rs("FunctionName").value) would work great!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top