Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Urgent help needed please

Hey people,

Basically, what I am trying to do is get a variable from a text box, and then after clicking submit, I would like to use the variable in my SQL statement as a conditional value to display the corresponding records. At present, the code prints the records whether the SQL condition is true or not.

This is the code:




<%
Dim rfidinput

rfidinput=Request.Form("rfid")

If rfidinput="" Then
%>



RFID:


<% Else %>

<%
Dim Conn, RS

Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")

DSNName = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
DSNName = DSNName & Server.MapPath("/database/medicalert.mdb")
Conn.Open DSNName

sql = "SELECT * FROM PersonalDtls WHERE (((PersonalDtls.RFID)=rfid))"

RS.Open sql, Conn, 3, 3

do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
Response.Write("
")
rs.MoveNext
loop
%>

<% End If %>





Comments

  • weapon__xweapon__x Member Posts: 138
    : Hey people,
    :
    : Basically, what I am trying to do is get a variable from a text box, and then after clicking submit, I would like to use the variable in my SQL statement as a conditional value to display the corresponding records. At present, the code prints the records whether the SQL condition is true or not.
    :
    : This is the code:
    :
    :
    :
    :
    : <%
    : Dim rfidinput
    :
    : rfidinput=Request.Form("rfid")
    :
    : If rfidinput="" Then
    : %>
    :
    :
    :
    : RFID:
    :
    :
    : <% Else %>
    :
    : <%
    : Dim Conn, RS
    :
    : Set Conn = Server.CreateObject("ADODB.Connection")
    : Set RS = Server.CreateObject("ADODB.Recordset")
    :
    : DSNName = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
    : DSNName = DSNName & Server.MapPath("/database/medicalert.mdb")
    : Conn.Open DSNName
    :
    : sql = "SELECT * FROM PersonalDtls WHERE (((PersonalDtls.RFID)=rfid))"
    :
    : RS.Open sql, Conn, 3, 3
    :
    : do until rs.EOF
    : for each x in rs.Fields
    : Response.Write(x.name)
    : Response.Write(" = ")
    : Response.Write(x.value & "<br />")
    : next
    : Response.Write("
    ")
    : rs.MoveNext
    : loop
    : %>
    :
    : <% End If %>
    :
    :
    :
    :
    :
    instead of this :

    sql = "SELECT * FROM PersonalDtls WHERE (((PersonalDtls.RFID)=rfid))"

    try this:
    sql = "SELECT * FROM PersonalDtls WHERE (((PersonalDtls.RFID)=" & rfidinput & "))"
    that is--> i assume rfid is a number...



    baboy... baboy...

    weaps

Sign In or Register to comment.