...

View Full Version : field.value in sql query



lgaquino
03-14-2006, 05:42 PM
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:

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%>

}



<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:thumbsup:

miranda
03-14-2006, 11:45 PM
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?

miranda
03-14-2006, 11:47 PM
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?

lgaquino
03-15-2006, 02:02 PM
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

degsy
03-15-2006, 03:32 PM
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.

lgaquino
03-15-2006, 07:01 PM
yeah, that idea crossed my mind. regardless, i solved the problem using yet another page to select which to load.

thx!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum