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

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

June 15th, 2012, 02:46 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

June 15th, 2012, 03:35 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 15th, 2012, 03:51 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 15th, 2012, 04:04 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 15th, 2012, 04:19 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 15th, 2012, 04:31 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 15th, 2012, 04:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Looks like dsource is not a valid server name, or doesn't run SQL Server....
Imar
|
|

June 15th, 2012, 04:59 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
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
%>
|
|

June 15th, 2012, 05:21 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |