p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Having trouble with Server.Transfer


Message #1 by phillip.a.kimble@g... on Fri, 7 Sep 2001 22:15:02
I am testing a login process with three programs.  The first allows the 
user to enter a username and password.  The second validates the entries 
and if there is no match from the database (MS Access), I send a message 
to the third program to print an ALERT to the screen and then send the 
user back to the first program.  Both the first and second programs must 
hit the database.  The problem is that the database seems to be tied up 
from the second program for the return to the first program and I get the 
message:

    Microsoft JET Database Engine (0x80004005)
    Could not use ''; file already in use.

I would like to use this method of poping up messages between other 
programs in my application as well, so I need to understand why the 
Server.Transfer does not seem to allow the "set rs = nothing" to really 
close the recordset and release the database.  I have tried the 
Response.Redirect, but this does not print my popup Alerts.

Thank you for your help!!

Code snippets I am using are:

SIGNON.ASP (Program 1)

Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = strConnect

strCommand = "SELECT * FROM Parms"

objComm.CommandText = strCommand
objComm.CommandType = adCmdText

Set objRS = objComm.Execute

If objRS.EOF Then ......

SIGNONVALIDATION.ASP (Program 2)

Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = strConnect

strCommand = "SELECT Username, Password, RoleCode FROM Login WHERE "
strCommand = strCommand + "Username LIKE '" & Request.Form ("Username") 
& "'"

objComm.CommandText = strCommand
objComm.CommandType = adCmdText
Set objRS = objComm.Execute

If Not objRS.EOF Then
  strUsername = objRS("Username")
  strPassword = objRS("Password")
  objRS.Close
  Set objRS = nothing

  If (Request.Form ("Password") = strPassword) Then
    Session("UserID")    = strUsername
    Server.Transfer "ALCSelect.asp"
  Else
   Session("Message") = "Sorry, you have provided an invalid password.  
Please try again." 
  End If    
Else
   Session("Message") = "Sorry, you have provided an invalid username.  
Please try again."
End If

Server.Execute "messager.asp"

Server.Transfer "SignOn.asp"

MESSAGER.ASP (Program 3)

<BODY>
<%
Dim strMessage
strMessage = """" + Session("Message") + """"
%>
<SCRIPT LANGUAGE=JavaScript>
alert(<%= strMessage %>)
</SCRIPT>
</BODY>

  Return to Index