Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple users writing to same database

Status
Not open for further replies.

Roel018

Programmer
Jun 12, 2002
30
NL
Hi All !!
Hope you can help me out...

I'm having this asp application where the visitor is able to send a message to an Access database.. This works great (with the code below).

However, when two or more users simultaneously send a message to the database, only ONE message get's saved..

Now, I know this has something to do with lock/unlocking the database.. But how do I implement this in my code ?? I have tried everything but it wont work.. I keep getting errors.

Here I provide my clean, working code (of course no simultaneously sending of messages possible yet):



============================================================
<%

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

Dim DBConn, strDB, strInsertSQL, chatname, messagetxt, messagetime, recordTotalFlash
strDB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("data/messages.mdb")

chatname=Request("chatname")
messagetxt=Request("messagetxt")
messagetime=Request("messagetime")
recordTotalFlash=Request("recordTotalFlash")

strInsertSQL="Insert Into Messages (chatname, messagetxt, messagetime) Values ('" & chatname & "','" & messagetxt & "','" & messagetime & "')"


if chatname<>"" and messagetime<>"" then
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open strDB
DBConn.execute strInsertSQL
response.write "&messageStorageSuccess=1"



if recordTotalFlash>50 then
response.write "&SizeAbove50"
strDELETESQL = "DELETE * from Messages WHERE id < ((SELECT MAX(id) FROM Messages) - 36)"


Set DBConn = Server.CreateObject("ADODB.Connection")

DBConn.Open strDB
DBConn.execute strDELETESQL
DBConn.update
DBConn.close
Set DBConn=Nothing
end if


Else
response.write "&messageStorageSuccess=0"
End If


DBConn.close
Set DBConn=Nothing
%>

============================================================



Hope someone knows how I can make sure all messages arrive at the datasbase .... Isn't there a way to qeue the instructions ????

Kind regards,
Roel
 
I suggest you try this one..but it is supposes to be used only in Access Forms..but maybe you can adapt the methods..
What you should do is..create a button,and on the button code builder write this one " docmd.requery" so, each time the user click the button even simultaneously, it will gives a slight delay to the computer thus, making the que become sequence..TRY IT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top