Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Updating with asp pages to access database. Simple question


Message #1 by saslaw@c... on Thu, 1 Aug 2002 01:01:07
Hi all.
I have a very simple question. Is it possible to update two tables in one 
database from one form on one asp page based on one single submit button?

I have searched for an answer but to no avail.

Al
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 1 Aug 2002 11:03:03 +1000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <saslaw@c...>
Subject: [access_asp] Updating with asp pages to access database. Simple
question


: Hi all.
: I have a very simple question. Is it possible to update two tables in one
: database from one form on one asp page based on one single submit button?
:
: I have searched for an answer but to no avail.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<%
strVar1 = Request.Form("txtFirstField")
strVar2 = Request.Form("txtSecondField")

strVar1 = SafeSQL(strVar1)
strVar2 = SafeSQL(strVar2)

strSQL1 = _
    "UPDATE Table1 " & _
    "SET Field1 = '" & strVar1 & "'"


strSQL2 = _
    "UPDATE Table2 " & _
    "SET Field2 = '" & strVar2 & "'"

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strDBConnection

objConn.Execute strSQL1,,adCmdText+adExecuteNoRecords
objConn.Execute strSQL2,,adCmdText+adExecuteNoRecords

objConn.Close
Set objConn = Nothing

Function SafeSQL ( _
    ByVal strToRenderSafe _
    )

    SafeSQL = Replace(strToRenderSafe, "'", "''")

End Function
%>


  Return to Index