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 October 16th, 2006, 10:23 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dparsons everything works perfect now.

It amazes me how fast and good you are at your asp scripting language, I was wondering what book you've read or how can I become as good as you are??

Because I can keep on asking you questions, and I think I will become an annoyance over some time....


-------------------------
peace, luv and respect
 
Old October 16th, 2006, 10:38 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The best teacher is practice, practice, practice ;] To be 100% honest with you I can only recall 3 books that I have read in regards to Classic ASP

They were:
  Sams Teach Yourself ASP in 24 Hours
  Sams Using ASP for Ecommerce Websites (I *think* that is what it was called)
  Wrox ASP 3.0 (the title was a bit longer but it alludes me)

I never read these books cover to cover, i used them as reference when I needed them. Depending on how you learn books may or may not be a good idea, I had them for a point of reference but I can't learn from reading a book I actually have to do it. (Hence why I never read the books cover to cover)

In any case, no book can replace experience (I have been programming for some time ;]) so don't get frustrated practice practice practice!

And when you get stuck there are always members around that can answer your questions =]

hth

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 16th, 2006, 11:36 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok here is another issue I have with my page:

I have made an online database, where you can register persons; view the members; delete etc. And there are a lot of pages.

To access the database you have to login. So on each of these pages I have put a session and session time out code

So each page consists of these codes

<% @Language = "VBScript" %>
<% If Session("yesmedewerker") = True then %>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Session.Timeout = 45 %>

<html>


 Codes

</html>

<% Else %>

<html>

<body>
Session expired
</body>

</html>

<% End If%>

ISSUE:
I tried to put an include file for the session expires but it wont work.



Codes:
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

Session.Timeout = 1
%>

And is there maybe another way to omit this code:

<% Else %>

<html>

<body>
Session expired
</body>

</html>

<% End If%>




-------------------------
peace, luv and respect
 
Old October 16th, 2006, 12:09 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Wh do you have timeout set to 45 in one version of code and the other set to 1? Also, includes are processed before the page is rendered so there is no reason that this shouldn't work if, in fact, the code in your include works.

I would suggest changing your .asp extension to .inc on your include files as well.

hth

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 21st, 2006, 11:16 PM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another issue I have with updating the admins info:

Here I have the code of admin.asp where I view the username and passwords of the administrators of the website. On this page I can modify the administrators of the page where their username and passwords are seen in a textbox.

<%
Dim strUserName, i
Dim adoCon 'Holds the Database Connection Object
Dim rsMiembro 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb")

'Create an ADO recordset object
Set rsMiembro = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM admin ORDER BY user;"

rsMiembro.CursorLocation=3 'clientside
rsMiembro.CursorType=3 'staticrecordset

'Open the recordset with the SQL query
rsMiembro.Open strSQL, adoCon

    Response.Write ("<form name=form method=post action=admin_update_entry.asp>")
    Response.Write ("<br><table cellpadding=0><tr>")
    Response.Write ("<td><b>Username:</b></td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("<td><b>Password:</b></td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("<td><b>Role:</b></td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("<td>&nbsp;</td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("</tr>")

'Do While not rsMiembro.EOF
For i=1 To 24
If Not rsMiembro.eof And Not rsMiembro.bof Then

    'Write the HTML to display the current record in the recordset
    Response.Write ("<tr><td>")
    Response.Write ("<input size=9 type=text name=user value=" & rsMiembro("user") & ">")
    Response.Write ("</td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("<td>")
    Response.Write ("<input size=9 type=text name=password value=" & rsMiembro("password") & ">")
    Response.Write ("</td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("<td>")
    Response.Write ("<input size=9 type=text name=role value=" & rsMiembro("role") & ">")
    Response.Write ("</td>")
    Response.Write ("<td width=10>&nbsp;</td>")
    Response.Write ("<td><a href=del_entry.asp?ID=" & rsMiembro("id") & " target=_self>" & "del" & "</a></td>")
    Response.Write ("<td align=middle>/</td>")
    Response.Write ("<td ><a href=upd_entry.asp?ID=" & rsMiembro("id") & " target=_self>" & "upd" & "</a></td>")
    'Response.Write ("<input type=hidden name=id value=" & rsMiembro("id") & "><td><input type=submit name=submit value=Edit></td>")
    Response.Write ("</tr>")
    'Move to the next record in the recordset
    rsMiembro.MoveNext
End If
Next
'Loop
Response.Write ("</form>")

%>

This is the code for the update. E.g. the username is placed in a textbox with the code above and I just change the password and click on “upd” to update the password.

<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query for the database
Dim lngRecordNo 'Holds the record number to be updated

'Read in the record number to be updated
lngRecordNo = CLng(Request.Form("id"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM admin WHERE id=" & lngRecordNo

'Set the cursor type we are using so we can navigate through the recordset
rsUpdateEntry.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsUpdateEntry.LockType = 3

'Open the tblComments table using the SQL query held in the strSQL varaiable
rsUpdateEntry.Open strSQL, adoCon

'Update the record in the recordset
rsUpdateEntry.Fields("user") = Request.Form("user")
rsUpdateEntry.Fields("password") = Request.Form("password")
rsUpdateEntry.Fields("role") = Request.Form("role")


'Write the updated recordset to the database
rsUpdateEntry.Update

'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing

'Return to the update select page incase another record needs deleting
Response.Redirect "admin.asp"
%>

But when I click to update I get this error code:

Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/excel_registrashon/admin/upd_entry.asp, line 36


Line 36:
rsUpdateEntry.Fields("user") = Request.Form("user")



-------------------------
peace, luv and respect
 
Old October 22nd, 2006, 10:11 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Response.Write this line: "SELECT * FROM admin WHERE id=" & lngRecordNo then exectue the query that is in your database. See if the row actually exists and the query is what you expect it to be.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 22nd, 2006, 04:29 PM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my database I have no queries. I just add, view, delete and update with asp and the row does exists.


-------------------------
peace, luv and respect
 
Old October 23rd, 2006, 07:39 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am saying, execute the query in your asp code inside of your database so that the row you think you are returning actually exists in your database.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 23rd, 2006, 09:39 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the line that executes the query:
rsUpdateEntry.Open strSQL, adoCon



-------------------------
peace, luv and respect
 
Old October 23rd, 2006, 09:41 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No i mean do:

response.write strSQL out to the screen then, whatever that query is, execute it inside of your database.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
Count string occurences across recordset goldstein SQL Server 2005 1 July 9th, 2007 06:47 PM
You maybe at the end of a recordset? seananderson Access 1 March 19th, 2007 07:57 AM
showing an image till a page gets loaded harshaghanta ASP.NET 2.0 Basics 0 May 10th, 2006 01:37 PM
SQL record count / recordset chacquard Access VBA 4 July 3rd, 2004 04:41 AM
Recordset count niravp Classic ASP Databases 6 October 26th, 2003 02:41 PM





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