Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question field.value in sql query

    hello, sort of n00b question, if you could answear, it'd help me big time!

    i have this form, which contains a text field and a submit button, and an asp function that gets the text value, put it in a sql query that searches in my data base for a register containing the value in the text field (amongst other things). the function, depending on the result of the query, makes the form load one page or the other.

    the problem is that i can't get the query to get the text field value (unless in put an int() function, that also doesn't work). When i get the value, the query must have something wrong cos the following if doesn't work properly!

    here's the function, and the form code:
    Code:
    function megazord(){
    <%caminho="http://www.mongeral.seguros/"
    
    set conn=server.createobject("adodb.connection")
    conn.open "sysprev","deinf","mon8020"%>
    
    <%set sql_conta_imagem = conn.execute("select count(*) as cont from sysprev.swdb002 A, sysprev.swdb001 B where mt_seg="& request.form("mat_part") &"  and B.cd_doc = A.cd_doc and b.cd_doc between 1 and 30")
      if not sql_conta_imagem.eof then
      	x =  sql_conta_imagem("cont").value%>
    
    	<%if x <> 0 then%>
    		document.form2.action = "adigital_verif_LG.asp";
    		document.form2.submit;
    	<% else %>
    		document.form2.action = "emp_verif.asp";
    		document.form2.submit;
    	<%end if%>
      <%else%>
    	document.form2.action = "adigital_verif_LG.asp";
    	document.form2.submit;
      <%end if%>
    
    }
    Code:
         <form name="form2" method="post" onsubmit="megazord()">
            <input class = select type="text" name="mat_part" maxlength="12" size="20">
            <input class = button type="submit" name="ok" value="Ok">
            <input class = button type="reset" name="apagar2" value="Limpar">
    thanks

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    What error do you get? From the look of your sql query it looks like request.form("mat_part") has a numerical value.

    Did you try to do a Response.Write of your query?

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    What was your error message? Did you try to do a response.Write of your sql query?

    From the looks of the query, it looks like request.form("mat_part") has a numerical value. Is that correct?

  • #4
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, it does have a numeric value. however i didn't expect it to be an issue, since in other pages i use it regardless of the type.

    when i reponse.write the query result, i get the number of the select count. but when, inside the if, i check if it's <> 0 (and the result is 10 for instance) it goes to the else! then i reload. try again, and works. I change the number, the same happens. mixed counting, reload, correct count.

    the error msg is:
    "
    error type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token B was not valid. Valid tokens: FOR WITH FETCH ORDER UNION EXCEPT OPTIMIZE.
    /intranet/digitalizacao/digital/adigital_LG.asp, line 31
    "

    line 31 is the sql query line

    thx

  • #5
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would change the order in which you are doing things.

    You are jumping in and out of serverside ASP (VB?) and clientside Javascript.

    The way i see it the Javascript function is never going to get the correct value because when you first load the page it is populating the function not when you press submit.

  • #6
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeah, that idea crossed my mind. regardless, i solved the problem using yet another page to select which to load.

    thx!


  •  

    Posting Permissions

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