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 June 14th, 2012, 08:58 PM
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Question interface appeared

Hi Imar.

My whole interface now appeared..

i just removed the id="login" here:

[QUOTE=paulapaupau;284699
<form name="login" id="login>

[/QUOTE]

but still, after I tried to log in, my login page appears..

I think we narrowed down my problem.. thank you so much to you..

Paula
 
Old June 15th, 2012, 02:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I ran your code and I can see a whole bunch of problems.

1. You're missing method="post" on the form. GET is the default which means the user name and passwored are appended to the query string and won't be available in Request.Form

<form.... metjhod="post">

2. Your ADO code doesn't work. Take a look at this:

set Conn = server.createobject("adodb.connection")
Conn = "Provider=sqloledb;Data Source=datasource;" & _

First you say Conn is a connection object. On the second line you overwrite it with the connection string. You want to call something like Conn.Open (connectionString) instead.

3. No need to call this:

Set rs = Server.CreateObject( "ADODB.Recordset" )

A few lines below you already assign the rs variable from the call tyo execute,.

4. No need to call this:

rs.Open sql, Conn

You already have an open recordset from the call to Execute.

You may want to get started with a tutorial on using ADO in classic ASP, such as this one: http://www.w3schools.com/ado/ado_examples.asp A google search should bring up more useful stuff.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
paulapaupau (June 15th, 2012)
 
Old June 15th, 2012, 03:35 AM
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Unhappy

D'oh.. :(

1. I now changed my form into:
<form name="login" method="post" action="protectedpage.asp">

2. I also changed my ADO code:
set Conn = server.createobject("adodb.connection")
Conn.Open "Provider=sqloledb;Data Source=mondecar;" & _

3. I removed my:
Set rs = Server.CreateObject( "ADODB.Recordset" )
rs.Open sql, Conn



When I try to login, wether I input the correct username and password or not,
the protectedpage.asp appears.. :(

I'm so sorry for taking so much of your time..

Thank you,
Paula
 
Old June 15th, 2012, 03:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I'm so sorry for taking so much of your time..
You could speed up that process by posting the code of your page.....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 15th, 2012, 04:04 AM
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Question

Here's my new code Imar..

<%
Response.Expires = -1000
Response.Buffer = True
Session("UserLoggedIn") = ""
If Request.Form("username") <> "" And Request.Form("username") <> "" Then
CheckLogin
Else
ShowLogin
End If

Sub ShowLogin
%>




<body background="back.jpg">

<form name="login" method="post" action="protectedpage.asp">

<<h1><center> Company Name </center></h1>
<h2><center> Project System </center></h2>
<br/><br/><br/><p> <Center> Enter Username and Password </center> </p> <br/>
<p><center> USER NAME <input type="text" name="username"> <br/><br/> PASSWORD <input type="password" name="pword"><br/><br/>
<input type="submit" value="Login" >
</center> </p>

</form>


</body>



<%
End Sub

Sub CheckLogin
Dim Conn, rs, sql


set Conn = server.createobject("adodb.connection")
Conn.Open "Provider=sqloledb;Data Source=dsource;" & _
"Initial Catalog=catalog;User Id=id;Password=password;"


sql = "SELECT * FROM CarInfo WHERE EmpId = '"&username&"'"

Set rs = conn.execute(sql)

Session("UserLoggedIn") = "false"
Do While Not rs.EOF
If Request.form("username") = rs("EmpId") And Request.form("pword") = rs("Password") Then
Session("UserLoggedIn") = "true"
Exit Do
End If
rs.MoveNext
Loop
rs.Close
Conn.Close



If Session("UserLoggedIn") = "true" Then
Response.Redirect "protectedpage.asp"
Else
Response.Write("Login Failed.<br><br>")
ShowLogin
End If


End Sub

%>


Thank you,
Paula
 
Old June 15th, 2012, 04:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take a look at this:

Code:
 
<form name="login" method="post" action="protectedpage.asp">
You're posting to the protected page, while you should post to the Login page.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 15th, 2012, 04:31 AM
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Question

I got this error after I tried logging in..


Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

/hrselfservice/car/password.asp, line 52
 
Old June 15th, 2012, 04:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Looks like dsource is not a valid server name, or doesn't run SQL Server....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 15th, 2012, 04:59 AM
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Question

But if I ran this code, I can access my database and it displays my database.. This code and my login code have the same source..

<%

Dim Connection
Dim Recordset
Dim SQL


SQL = "SELECT * FROM tablename"


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

Connection.Open "DSN=datasource;UID=user;PWD=password;Database=dat abase"

Recordset.Open SQL,Connection

If Recordset.EOF Then
Response.Write("No records returned.")
Else

Do While NOT Recordset.Eof
Response.write Recordset("EmpID")
Response.write Recordset("Password")

Response.write "<br>"
Recordset.MoveNext
Loop
End If


Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
 
Old June 15th, 2012, 05:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Your connection strings differ. In the example that works, you use a DSN (which has been set up on your Windows machine). In the other, you're using dsource as the name of the server.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot log in brianrodda ASP.NET 2.0 Basics 1 July 15th, 2008 09:02 AM
How to log to server's event log LenexaKS Access VBA 4 March 11th, 2008 12:49 PM
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
Log out neil.abachi07 Classic ASP Basics 67 March 9th, 2007 07:02 AM
AppException Class -Log Error to Event Log bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 7 December 7th, 2004 01:01 PM





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