SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to check the return value of MySQL database???

    Hello,

    Now i got problem in my ASP page using VBScript that is implemented for IP Phone Service.I am trying to do directory service in IP Phone.So user key in the first name or last name.According to user input, it will go n look for the name in MySQL database.If the name is not found,it will return the error.My VBscript programming is bad.I cant check it out how i check the return for Record set from database.Anyone can help me??Following is my program.How should i check, if the database doesnt have the name, RSDirectory output....Thanks a lot

    <%@ Language=VBScript%>
    <%

    serverIP = Request.ServerVariables("LOCAL_ADDR")
    SERVICE_DIR="CiscoIPServices"
    Response.ContentType = "text/xml"
    Response.Buffer = true


    firstname="ang"
    lastname= ""

    set conn = server.createobject ("adodb.connection")
    conn.open "MyData", "root", "khaing"


    if (firstname="" And lastname="") then
    Response.Write("<IPPhoneText><Text>Please key in first name or last name</Text></IPPhoneText>")
    Response.End


    elseif(firstname <> "" and lastname="") then
    set RSDirectory = conn.execute("Select * from ecestuff where name like '% " &firstname& "%';")


    elseif(lastname <> "" and firstname="") then
    set RSDirectory = conn.execute("Select * from ecestuff where name like '% "&lastname&"';")

    else
    set RSDirectory = conn.execute("Select * from ecestuff where name like '% " &firstname& "%' and name like '%"&lastname&"';")

    end if




    Response.Write("<IPPhoneDirectory>")

    Do until RSDirectory.EOF
    name=RSDirectory("name")
    tel=RSDirectory("tel")
    position=RSDirectory("position")
    stuffid=RSDirectory("stuff_id")
    email=RSDirectory("email")



    Response.Write("<DirectoryEntry>")
    Response.Write("<Name> Name: " &name& "</Name>")
    Response.Write("<P>Designation: " &position& "</P>")
    Response.Write("<Telephone> Telephone: " &tel& "</Telephone>")
    Response.Write("<Email> Email: " &email& "</Email>")
    Response.Write("</DirectoryEntry>")

    RSDirectory.MoveNext
    loop

    Response.Write("</IPPhoneDirectory>")


    Response.Flush()
    Response.End()
    %>

  2. #2
    SitePoint Enthusiast Northern Star's Avatar
    Join Date
    Aug 2006
    Location
    Cheshire, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to make sure the recordset 'RSDirectory' isn't empty.

    Try using...

    Code:
    If RSDirectory.EOF Then
         Response.Write "Sorry, your search failed to produce any results!"
    Else
    
         Do Until RSDirectory.EOF
    
         '## INSERT YOUR OUTPUT CODE HERE
    
         RSDirectory.MoveNext
         Loop
    
    End If
    "If it ain't broken, don't fix it!"
    ----
    Northern Star - Web design, stategy & development.


Bookmarks

Posting Permissions

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