one function I Like in MSaccess was the Dlookup() when I start written ASP I miss that function so After about a Month I had Written the ASP version It Works for me and help me get data that i miss
Function ASPLookup(FieldName,TableName,Crit)
Dim Dsql , OfeildName, RecordSet, CheckIt
OfeildName = Trim(Left(Crit, InStr(Crit, "=") - 1))
CheckIt = Trim(Mid(Crit, InStr(Crit, "=")+1,len(Crit)))
Dsql = ""
Dsql = Dsql & "SELECT " & TableName & "." & OfeildName & "," & TableName & "." & FieldName
Dsql = Dsql & " FROM " & TableName & " "
Dsql = Dsql & " WHERE (" & TableName & "." & Crit & ");"
if CheckIt ="" or CheckIt="0" or OfeildName ="" then
ASPLookup = ""
Exit Function
Else
end if
'call writeit("Crit",Crit)
'call writeit("CheckIt",CheckIt)
'call writeit("DSQL",DSQL)
Set RecordSet = Server.CreateObject("ADODB.Recordset")
RecordSet.Open DSQL, connstring, adOpenKeyset, adLockPessimistic, adCmdText
If RecordSet.EOF Then
ASPLookup = ""
RecordSet.Close
set RecordSet = nothing
Exit Function
Else
ASPLookup = RecordSet(1)
RecordSet.Close
set RecordSet = nothing
Exit Function
End If
End Function
This Function Work like the dlookup(feild,table,where) in MSaccess
name = ASPLookup("surname","Customer","CustomerID=2")
only thing you have todo is create the connstring which is the string point to the MS or SQL dataset
OR
name = ASPLookup("surname","Customer","CustomerID=2 or Customer.login=1")
the Crit after the first must have the table name
check out the writeit Blog