SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Where..Or.. Like

    Hello

    Here is my code and so far it works

    Code:
    <%@ LANGUAGE = VBScript %>
    <% Response.Expires = 0 %>
    <!--#include file="../Area_Riservata/Sicurezza.asp"-->
    <!--#INCLUDE FILE = "IFormC.asp" -->
    <!--#INCLUDE FILE = "IForm06b.asp" -->
    <%
    Dim oConn
    Dim oRs, oRs2
    Dim MaxCols, Col
    Dim cd_cli, nome
    Dim s, intesta
    Dim risposta
    
    	cd_cli = request.form("txtCodFiscale")
    	nome = request.form("txtNome")
    
    	Set oConn = Server.CreateObject("ADODB.Connection")
        oConn.Open "Form_Store"
        Set oRs = Server.CreateObject("ADODB.Recordset" )
    
    	Set oRs = oConn.Execute("SELECT * FROM 000_REGISTRAZIONE WHERE COD_NOTAIO= '" & cd_cli & "' OR PA_NOME LIKE '%" & nome & "%'" )
    	
    	if (Not oRs.eof) then
    		MaxCols = oRs.Fields.count
    		for Col = 0 to MaxCols - 1
    			SetFieldValue "A" + oRs(Col).name, oRs(Col).value
    			'Session oRs(Col).name & oRs(Col).value & "<br>"
    			Set oRs2 = oConn.Execute("SELECT PA_COGNOME, PA_NOME FROM 000_REGISTRAZIONE WHERE COD_NOTAIO= '" & cd_cli & "' OR PA_NOME LIKE '%" & nome & "%'")
    		next
    		risposta = "<span class='Menu1Title'>Notaio selezionato: " & oRs2("PA_COGNOME") & " " & oRs2("PA_NOME") & "<br><br> Seleziona Precedente per ritornare sul Elenco Categorie per visualizzare il modulo</span> <br><br>"
    		oRs.close
    	else
    		risposta = "<span class='Menu1Title'>Il codice notaio richiestato non e stato trovato. </span>"
    	end if
    	
    
    %>
    <html>
    <head>
    <title>Intr@Form - Identificazione Sottoscritto</title>
    <link rel="stylesheet" type="text/css" href="Layout.css">
    <style type="text/css">
    <!--
    a:hover {  color: #990000}
    -->
    </style>
    </head>
    <script language="javaScript">
    function cmdBack()
    {
            window.location = '<%if s = "" then%>IForm01.asp<%else%>IForm01.asp<%end if%>';
    }
    </script>
    <body bgcolor="#FFFFFF">
    <table width="794" border="0" height="82">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="186" valign="top"><table border="0" cellspacing="1" width="158">
            <tr bgcolor="#E6E6E6">
              <td width="157" height="25"><a href="javascript:cmdBack()" class="Menu1Title">&nbsp;Precedente</a></td>
            </tr>
          </table></td>
        <td width="598"><%
    if cd_cli = "" then
    Response.Write risposta
    else
    Response.Write risposta
    end if
    %>
        </td>
      </tr>
    </table>
    </body>
    </html>
    In my code i take the selected query and i write in it the name and surname. But ermm what if i have alot of records and i want to show them to the user and let the user select which one it wants to pick.

    Like when the user serach for PA I want to show them

    Code:
    Code   Name            Surname             SELECT
    012     Patrizia         Bla                     ?
    123     Patrick          Hi                      ?
    852     Pamala          Bye                    ?
    Maybe i could use a check box to let the user select or even a simple href.

    Anyone??

    Thanks
    dReAm

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need to do the second query, all the information you are getting in the second query is already contained in the first one.

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    strSQL = "SELECT * FROM 000_REGISTRAZIONE WHERE COD_NOTAIO= '" & cd_cli & "' OR PA_NOME LIKE '&#37;" & nome & "%'"
    oConn.Execute strSQL
    oRs.open strSQL, oConn, 2, 3
    'Response.write strSQL

    if (Not oRs.eof) then
    MaxCols = oRs.Fields.count
    for Col = 0 to MaxCols - 1
    SetFieldValue "A" + oRs(Col).name, oRs(Col).value
    do while (not oRs.eof)
    Response.write oRs("PA_NOME")
    loop
    next
    else
    risposta = "<span class='Menu1Title'>Il dati dei notaio richiestato non e stato trovato. </span>"
    end if

    Ok my loop is wrong coz nothing happens
    What i want to do is take the 2 records "Patrizia, PAtrick" and write them in my response.write..

    How can i do the loop?
    Last edited by dreamduster; Jan 19, 2007 at 07:46.
    dReAm

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i fixed it.. thanks for the help

    here's the code
    Code:
    	if (Not oRs.eof) then
    		MaxCols = oRs.Fields.count
    		for Col = 0 to MaxCols - 1
    			SetFieldValue "A" + oRs(Col).name, oRs(Col).value
    			do while oRs.Fields.count - 1
    				response.write oRs("COD_NOTAIO") & " " & oRs("PA_COGNOME") & " " & oRs("PA_NOME") & "<BR>"
    				oRs.MoveNext				
    			loop
    		next
    	else
    		risposta = "<span class='Menu1Title'>Il dati dei notaio richiestato non e stato trovato. </span>"
    	end if
    dReAm

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im not sure what you're trying to do there but it looks weird.

    You are iterating through the FIELDS collection while you skip through the RECORDS.

    Maybe you want to do something like:
    Code:
    ' go through the records
    Do While Not oRS.EOF
    	' go through each field and call the "setfieldvalue" function
    	For Each oField In oRS.Fields
    		SetFieldValue "A" + oField.Name, oField.Value
    	Next
    	
    	response.write oRs("COD_NOTAIO") & " " & oRs("PA_COGNOME") & " " & oRs("PA_NOME") & "<BR>"
    	
    	oRS.MoveNext
    Loop


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
  •