November 10, 2011 at 2:11 am
USE tempdb
IF OBJECT_ID('t1') IS NOT NULL
DROP TABLE t1
GO
CREATE TABLE t1 (id INT PRIMARY KEY, name1 VARCHAR(10))
INSERT INTO t1
SELECT 1, 'name 1' UNION ALL
SELECT 2, 'name 2' UNION ALL
SELECT 3, 'name 3' UNION ALL
SELECT 4, 'name 4' UNION ALL
SELECT 5, 'name 5'
GO
'--------user 1 In visual basic 6.0 multi user problem
conn.begintrans
conn.excute "INSERT INTO t1 (id, name1)VALUES (6, 'name 6')"
Conn.CommitTrans
on debug mode excute upto second line of code
'--------user 2
conn.begintrans
conn.excute "INSERT INTO t1 (id, name1)VALUES (7, 'name 7')"
Conn.CommitTrans
now user 2 is excuting the code upto second line. now error will araise, because table is already opened to insert for user1. now user 2 will try to insert visual basic is getting error because table is opened.
COMMIT TRAN
November 10, 2011 at 2:43 am
If you're just executing a simple insert, why do you need an explicit transaction? If you want to do it like this, I think you'll need something in your VB script to trap the error and roll back the transaction.
John
November 10, 2011 at 2:59 am
I am developing application in multi-user mode. In every screen there is header and detail part of transaction. if user1 is adding header part and detail part. but he has not finished whole transaction.
-user2 transaction2
if user2 is adding header part and while adding detail part he will get error because of table lock.
is there any solution for the above issue.
November 10, 2011 at 3:38 am
Never code an application so that a transaction waits for user input. You'll have too many locking issues when users forget to complete their work before they go off for lunch.
John
November 10, 2011 at 3:46 am
Yes, correct
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply