I am running a query from ASP using a MySQL database, I want to create a variable (ssResult) based on the result with a person's name (fullname), if the record does not exist I want to assign the text 'N/A' to the variable, code below, I currently use a function getOther for my database connections which passes the column name "fullname":
ssResult = getOtherElse("SELECT fullname FROM table WHERE id=" & inArr(j), "fullname")
Below is the code for the function getOtherElse which only works when a result is returned but not when there is an empty result:
Function getOtherElse(inSQL, getColumn)
Dim conn, rstemp
Set conn = Server.CreateObject("ADODB.Connection")
conn.open myDSN
Set Session("lp_conn") = conn
Set rstemp = Server.CreateObject("ADODB.Recordset")
rstemp.Open inSQL, conn
if not rstemp.eof then
rstemp.movefirst
getOtherElse=rstemp.fields(getColumn)
else
getOtherElse="N/A"
end if
rstemp.close
set rstemp=nothing
conn.close
set conn=nothing
End Function
Thanks!