 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 22nd, 2004, 03:09 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Creating a log file for multiple users
I want to create a log file tracking the sequence in which pages are accessed, using a text file. Can multiple users append to a single text file, or do I need to do separate ones for each user? If the former, what happens if more than one user tries to append at the same time?
Thanks
Pat
-------------------
System 3 2000 Limited
www.system3-2000.co.uk
__________________
-------------------
System 3 2000 Limited
www.system3-2000.co.uk (but very out-of-date!)
|
|

June 22nd, 2004, 10:53 PM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
|
|
I think you can lock the file when logging the data, In this case if more than one user tries to append, then it will wait for one process to complete.
An alternative solution is to create table and store the activities in the database.
Om Prakash
|
|

June 22nd, 2004, 11:53 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am also facing a similar problem. Thanks for the suggestion Om Prakash.
But,how can I lock a file ? Could you please explain it in some detail ?
|
|

June 23rd, 2004, 05:04 AM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
|
|
You can use application object to lock:
For example:
<%
Application.Lock
'do some application object operations
Application.Unlock
%>
Please check the following URL, which might be useful..
http://www.sloppycode.net/asp/?m=2
Om Prakash
|
|

June 23rd, 2004, 05:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Application.Lock does not lock the entire application; all it does is block other ASP pages from writing to the variables stored in the Application object. This is to prevent two users from writing to those variables at the same time.
Even if it would work, it would be a bad idea. It's not very good for performance and availability to lock an entire application for *all* users, just because you need to write to a file.
Personally, I would never try to store information like this in a text file. Text files in Web applications are not an ideal scalable solution.
Why don't you use a database? Databases are designed for multi-user environments.....
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Micro cuts by Muse (Track 7 from the album: Origin of symmetry) What's This?
|
|

June 23rd, 2004, 05:35 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello Imar,
Suppose we keep the log details in a database, will it be automatically multi-user friendly ? Or should we use stored procedures with transactions ?
|
|

June 23rd, 2004, 05:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
That depends on the database and the number of users. Most databases are multi user, so you shouldn't have a problem. But some database are limited by the number of users they can serve. Technically, an Access database cannot handle more than 255 users at the same time, but in practice, this limit is hit much sooner.
There is no real need to use stored procedures and transactions, just to enable a multi-user scenario. However, when data integrity is important, you'll have to use transactions anyway (even if you were the only user). You'll also find that Stored Procedures will make database / application development much easier in the end.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Sunburn by Muse (Track 1 from the album: Showbiz) What's This?
|
|

June 23rd, 2004, 06:08 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello Imar,
Thanks for this reply.
|
|

June 24th, 2004, 01:06 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi imar,madhu
i am also planning to use a log file in my application .. about locking what i wanted to say that instead of locking the application if we lock the database file while we append the lock activities, wont it be a better idea ..
bocz acc. to my knowledge of database locks ... if the database is locked and another request comes that the new request is put in a queue until the first lock is opened ... so i think it will work fine ...more over i will never face the problem about the 255 users of ACCESS which i am using bcoz my application will be used atmost by 50 people all togather ....
so i need ur views on this ...
Sudhan.
|
|

June 24th, 2004, 01:26 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi silver_cuts,
I agree with you totally. But I don't know how can I lock and unlock an access / sql server database. I have been searching for this for a long time.
I know how to lock a MySQL database. But I don't find similar features for MS Access and SQL server.
|
|
 |