Please Help me =)

Results 1 to 2 of 2

Thread: Please Help me =)

  1. #1
    Join Date
    Dec 1969

    Default Please Help me =)

    Hi am getting into databases and am pretty much a newbie<BR>i have been expermenting with things hoping for them to work right and when (if) they do i know i did something sorta right and i keep learning...<BR><BR>anyways i setup a dsn with the name "login" and a login.mdb file in access 2000<BR><BR>i made a page and eventually when you login, it will compare the user name and pass to the database but i am having trouble connecting it..<BR><BR>please help me~ thanks~!!<BR><BR>here is the code...<BR><BR>&#060;%@ language="vbscript" %&#062;<BR><BR>&#060;% Option Explicit %&#062;<BR><BR>&#060;% Response.Expires = 0 %&#062;<BR><BR>&#060;% Dim url, strname, strpass %&#062;<BR><BR>&#060;%<BR>url = Request.form("url")<BR>strname = Request.form("name")<BR>strpass = Request.form("pass")<BR>%&#062;<BR><BR>&#060;%<BR> IF isempty(url) OR url = "" THEN<BR>url = "index.asp"<BR>END IF<BR><BR><BR>Dim dodb, X, connection<BR>dodb="SELECT * FROM login WHERE name = " & strname & " AND pass = " & strpass<BR><BR><BR>Set connection=Server.CreateObject("ADODB.Connection") &#039creates object to manipulate DB<BR> "login" &#039name of dsn<BR>Set X=connection.execute(dodb) &#039do stuff to DB<BR><BR><BR>IF NOT X.EOF THEN<BR>Session("authenticated") = true<BR>connection.close<BR>Response.Redirect url<BR>ELSE<BR>connection.close<BR>Response.Redire ct "invalid.asp?"<BR>END IF<BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Please Help me =)

    Try adding quotes to your sql statement as follows:<BR><BR>Dim dodb, X, connection<BR>Dim strSQL<BR><BR>strSQL ="SELECT * FROM login WHERE name = &#039" & strname & "&#039 AND pass = &#039" & strpass & "&#039"<BR><BR>Create a connection string and change the user id and password where appropriate:<BR><BR>dim strDSN<BR>strDSN = "dsn=LOGIN;uid=admin;pwd=;"<BR><BR>Also, create a recordset object and use it to get stuff from the database:<BR><BR>Set objRst = Server.CreateObject("ADODB.Recordset")<BR>objRST.o pen strSQL, strDSN<BR><BR>Hope this helps.<BR><BR><BR><BR>

Posting Permissions

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