Need help - Ado recordset not working

Results 1 to 2 of 2

Thread: Need help - Ado recordset not working

  1. #1
    Join Date
    Dec 1969

    Default Need help - Ado recordset not working

    Hello and HELP, Im using a recordset to read from an active directory. I get an "An unhandled data type was encountered."<BR>error when I try to access the values. I´ve checked to see if the value is null but it is not, I also tried converting it to CStr() but that caused a Type mismatch. I have no clue of what I should try next? I made a VB program with the same code which works perfectly, also tried the same ASP code on another computer which worked perfectly. What could I be doing wrong?<BR><BR>&#060;%@ Language=VBScript%&#062;<BR>&#060;HTML&#062;<BR>&# 060;body MS_POSITIONING="GridLayout"&#062;<BR>&#060;% <BR> &#039;Connecting to an active directory<BR> Set adsRootDSE = GetObject("GC://RootDSE")<BR> strADsPath = "GC://"&adsRootDSE.Get("rootDomainNamingContext")<BR><BR > strBase = "&#060;" & strADsPath & "&#062;"<BR> <BR> Set adsRootDSE = Nothing<BR> <BR>&#039;Want to find a person with the name strPerson - sn = surname<BR> strObjects = "(objectCategory=person)"<BR> strPerson = "Smith"<BR> strName = "(sn=" & strPerson &"*)"<BR> <BR> strFilter = "(&" & strObjects & strName & ")"<BR> strAttributes = "sn"<BR> strScope = "subTree"<BR> <BR> Set adoConnection = Server.CreateObject("ADODB.Connection")<BR> adoConnection.Open "Provider= ADsDSOObject;"<BR> Set adoCommand = Server.CreateObject("ADODB.Command")<BR> adoCommand.ActiveConnection = adoConnection<BR> <BR> adoCommand.CommandText = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope<BR> <BR> Set adoRS = adoCommand.Execute<BR> <BR> if adoRS.eof then<BR> Response.Write("The Recordset was empty")<BR> else <BR> if IsNull(adoRS.Fields("sn"))= false then <BR> Response.Write( adoRS.Fields("sn").Value ) THE ERROR IS HERE - <BR>end if<BR>end if <BR>%&#062;<BR>&#060;/body&#062;<BR>&#060;/HTML&#062;<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default try debugging a little

    replace this:<BR><BR>if IsNull(adoRS.Fields("sn"))= false then <BR>Response.Write( adoRS.Fields("sn").Value ) THE ERROR IS HERE - <BR>end if<BR><BR>with this:<BR><BR>returnvalue= objRS.fields(0) <BR>if isArray(returnvalue) then <BR> for i = lbound(returnvalue) to ubound(returnvalue) <BR> if returnvalue(i) &#060;&#062; "" then <BR> response.write(returnvalue(i) & " ") <BR> end if <BR> next <BR>else <BR> response.write(returnvalue & " ") <BR>end if <BR><BR>Good luck<BR>Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts