Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Unable to show "Data not found!" when searching data. That is not found in database .


Message #1 by "Grace" <grace_ng40@h...> on Wed, 25 Apr 2001 14:47:57
Here is my code for searching data input by user:



set oConn=Server.CreateObject("ADODB.Connection")

set oRS=Server.CreateObject("ADODB.recordset")

strSource = "DRIVER={Microsoft Access Driver (*.mdb)}; 

DBQ=C:\Inetpub\wwwroot\ws8_data.mdb"

oConn.ConnectionString = strSource

oConn.Open



If request.form("id")<>"" then

        sqltext = "SELECT * FROM Data "

        sqltext = sqltext & " WHERE ID='" & request.form("id") & "';"

        oRS.Open sqltext, oConn

        oRS.MoveFirst





End If



If request.form("name")<>"" then

                sqltext = "SELECT * FROM Data "

                sqltext = sqltext & " WHERE Name='" & request.form("name") 

& "';"

                oRS.Open sqltext, oConn

                oRS.MoveFirst



End If





If request.form("course")<>"" then

           sqltext = "SELECT * FROM Data "

           sqltext = sqltext & " WHERE Course='" & request.form("course") 

& "';"

           oRS.Open sqltext, oConn

           oRS.MoveFirst

End If





If request.form("email")<>"" then

               sqltext = "SELECT * FROM Data "

               sqltext = sqltext & " WHERE Email='" & request.form

("email") & "';"

               oRS.Open sqltext, oConn

               oRS.MoveFirst



End If



If request.form("phone")<>"" then

          sqltext = "SELECT * FROM Data "

          sqltext = sqltext & " WHERE Phone='" & request.form("phone") 

& "';"

          oRS.Open sqltext, oConn

          oRS.MoveFirst



End If

%>

<%

If oRS.EOF then

   response.write "No data found! Please enter again!!"

End If

%>        






  Return to Index