Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2005, 08:07 PM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem With variables and forms

Hello, I wrote the following code:

<% @LANGUAGE=VBScript %>
<%
    If Session("userName") = "" Then
        Response.Redirect("default.asp")
    End If

    dim oConn, sqlText, oRSdb, theUser, oldPass, newPass1, newPass2

    theUser = LCase(Request.Form("txtUserName"))
    oldPass = Request.Form("txtUserPass")
    newPass1 = Request.Form("newPass1")
    newPass2 = Request.Form("newPass2")

    Response.Write theUser & "<BR>" & oldPass & "<BR>" & newPass1 & "<BR>" & newPass2 & "<BR>"

    sqlText = "SELECT * FROM USUARIOS WHERE usuario = '" & theUser & "' " & "AND senha = '" & oldPass & "';"

    set oConn=Server.CreateObject("ADODB.connection")
    oConn.open "DRIVER={SQL Server}; SERVER=msde20i.terraempresas.com.br; DSN=neumans; UID=neumans; PWD=q5r8f3b8"
    Set oRSdb = Server.CreateObject("ADODB.Recordset")
    oRSdb.Open sqlText, oConn
    oRSdb.MoveFirst()

    Dim theUserDB
    theUserDB = LCase(oRSdb("usuario"))

    Response.Write "The user is " & theUserDB

    If theUser = theUserDB Then
        Response.Write "OK."
    Else
        Response.Write "You have to find another solution..."
    End If
%>

The problem is: I never get a successfull result when I compare the form user data with the sql database data. I'd like to get the "OK" response at the final and not "You have to find another solution...". I'd like to compare the variable that holds the form data and the variable that holds the db data and do some code forth, but they always don't be equal, even if I put all the correct data that I have in my db. Anyone can help me about this? Please, I'm almost crazy about...

 
Old November 8th, 2005, 02:02 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

It might be due to your datatype in the database. If you are using char and setting the length then it will never equal your form input, not unless of course you Trim the data from the database. That might work:

theUserDB = Trim(LCase(oRSdb("usuario")))

You could also try changing the datatype in the database to varchar.

Let me know if this works. Also, post some sample data






Similar Threads
Thread Thread Starter Forum Replies Last Post
accessin variables from various forms anandthecoolest C# 2005 2 March 8th, 2007 03:18 AM
Simple 'passing variables between forms' issue... overture C# 4 October 14th, 2005 02:30 PM
Passing variables between forms arcuza General .NET 1 July 11th, 2005 09:08 AM
Forms and variables Dai Beginning PHP 4 June 19th, 2003 02:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.