Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old June 24th, 2004, 02:31 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What is there to lock? You're building a logging facility, right? This means you're doing INSERTs exclusively, I think. "User 1 visits page 1", "User 1 visits page 2", "User 2 visits page 1" etc etc.

In such a scenario, you have nothing to lock. Just send your INSERT statements to the database. The database engine will deal with concurrency issues regarding writing to the database at the same time; this is not something you have to control yourself.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #12 (permalink)  
Old June 24th, 2004, 03:49 AM
Authorized User
 
Join Date: Jun 2004
Location: , , India.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to silver_cuts Send a message via Yahoo to silver_cuts
Default

Imar,Madhu

well madhu you gave me the answer in the recordset querry that i had asked ... u see as there is a CURSORTYPE there is also a LOCKTYPE which u can set to the desired value .... depends on the priorty of the transaction that you are going to perform on the database ...

well imar i didnt know that access has its own locks which are applied automatically bcoz as i said i have always used explicit lock on my ACCESS database .. i only know that ORACLE uses implicit locking as well as explicit locking mechanisms ...

finally i have never used MYSQL or SQL server and hence dont know anything about them ...

Sudhan.

Reply With Quote
  #13 (permalink)  
Old June 24th, 2004, 03:56 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What explicit locks in Access are you talking about? Can you give a code example? Or are you talking about the LockType enumeration?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Another Night In - Tinderstick by Faithless (Track 8 from the album: Back To Mine) What's This?
Reply With Quote
  #14 (permalink)  
Old June 24th, 2004, 04:07 AM
Authorized User
 
Join Date: Jun 2003
Location: Witham, Essex, United Kingdom.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not talking about file locks in Access. I wanted exclusive write access to a text file while a line was being written to it.

As there does not appear to be any facility in ASP/VBScript to lock a text file, I am using an Application variable to indicate that the file is in use while a line is being written.

The purpose of the log file is for tracking only, in an attempt to find out why a cookie key value is being lost. I decided not to use a database, as some have suggested, as the size of the database would grow rapidly with what would be, in a few hours, redundant data and there is no compelling reason for using a database.

Thanks to all for your input.

Pat

-------------------
System 3 2000 Limited
www.system3-2000.co.uk
Reply With Quote
  #15 (permalink)  
Old June 24th, 2004, 04:09 AM
Authorized User
 
Join Date: Jun 2004
Location: , , India.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to silver_cuts Send a message via Yahoo to silver_cuts
Default

Imar,

i am talking about LOCKTYPE enumeration ...
is it different from locking

Sudhan.

Reply With Quote
  #16 (permalink)  
Old June 24th, 2004, 04:31 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

No, but I thought you said you were locking Access yourself. Using the LockType is the correct way to indicate to the database how you want your locks applied.....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Stay by Tricky (Track 1 from the album: Vulnerable) What's This?
Reply With Quote
  #17 (permalink)  
Old June 24th, 2004, 05:49 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I know it is wrong to post PHP codes in this forum. But I want to explain a situation and the code is not that difficult also.

if(mysql_query("LOCK TABLES tbl_basic_submission WRITE",$cid_webilicious))
    {
        }
    else{
        echo(mysql_error());
    }

    $qry_insert_basic_submission = "insert into tbl_basic_submission (".$str_fields.") values(".$str_values.")";
    if(mysql_query($qry_insert_basic_submission,$cid_m ine))
    {
    }
    else{
        echo(mysql_error());
    }

    $i_order_id = func_getfield($str_connection,"select max(order_id) from tbl_basic_submission");
    //echo($i_order_id);
    if(mysql_query("UNLOCK TABLES",$cid_mine))
    {
    }
    else{
        echo(mysql_error());
    }

This will first lock the table. Then insert one record. Then get the primary key of the newly inserted record. (This value is needed for inserting a number of records into another table). This can be nicely done in PHP.

However the same thing could not be done in ASP, I think. Because, there is no way to lock the table for write operation. So the primary key value returned may not be correct as in between another record may have got inserted.

I am inviting your opinions into this issue. This case does require locking.
Reply With Quote
  #18 (permalink)  
Old June 24th, 2004, 06:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Madhukp,

I would suggest you to post that in a separate/different topic, as this gets diverted from the original topic posted by Pat. Also Pat might be still expecting something related to his requirement, but only to read all these posts, as he has said
Quote:
quote:I decided not to use a database
Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
  #19 (permalink)  
Old June 24th, 2004, 06:18 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, true, this is an issue with databases like Access.

There are a couple of ways around this, but probably not as easy as the way you do it in MySQL. None involve locking, though. IMO, locking will hinder scalability and performance of your application, while there are other ways available. (If it was as easy as in your PHP / MySQL example, I'd use it though)

1. Create the ID before you do the insert. Create a query that returns the next ID for a table. Not a very nice solution, though.

2. Use GUIDs for the ID. They are globally unique so a conflict will not occur. You can create a GUID before you execute the INSERT statement, and then pass in that GUID as the ID.

3. Use AddNew(). I think if you create a recordset and then use the AddNew method (as opposed to direct SQL statements), Access will correctly handle the new record. So, after you call Update, MyRecordset("ID") will contain the new ID.

4. If your records have a unique signature, you could requery the entire record for all its fields to get the ID. Then again, a composite key might be more appropriate.

5. Retrieve the ID using @@IDENTITY. Not 100% guaranteed to return the right ID, but for most applications I believe it to be close enough.

In SQL Server you could use @@SCOPE_IDENTITY to limit the scope of the ID that is returned. In combination with a Stored Procedure, that would be the way I would do it in any professional application, but it requires the use of SQL Server.

Cheers,

Imar




---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Millennium by Ed Rush & Optical (Track 4 from the album: Wormhole #1) What's This?
Reply With Quote
  #20 (permalink)  
Old June 24th, 2004, 08:14 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Let us continue discussion on this in the issue

<a href="http://p2p.wrox.com/topic.asp?TOPIC_ID=15255" target="_blank">DB Table locking</a>

as Vijay has suggested.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a list of users DennyLoi Javascript How-To 0 November 9th, 2007 04:32 AM
Creating Users through Front End feets SQL Server 2000 0 November 2nd, 2007 03:32 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
problem for creating the separate log file for con goel_man Apache Tomcat 0 December 19th, 2004 11:48 AM
Creating a log file from actions taken in a form lguzman Access VBA 2 November 3rd, 2004 10:58 AM



All times are GMT -4. The time now is 04:43 PM.


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