Posting info to two separate tables (Full Version)

All Forums >> [Web Development] >> ASP, PHP, and Database



Message


fredecd -> Posting info to two separate tables (7/14/2004 16:07:46)

I think I saw this question answered before, but could not find it using the search.

I would like to keep a log of when records are edited. Can I post the same information to two different tables at once?




Spooky -> RE: Posting info to two separate tables (7/14/2004 17:41:50)

Not so much at once - but with 2 executed SQL statements.
As its more than likely to a different table in a different database, youll need a different connection.

Basically the code will be duplicated exactly the same bar the connection




fredecd -> RE: Posting info to two separate tables (7/15/2004 11:30:46)

Here is the code that I am trying to use. What I am trying to do is to post the information to one table as a new record, then update the main table.

My update is going through, but it only adds a blank record to the other table. All of this code is DRW generated, but I clipped the "add_new" code from another page and pasted it in.

Any ideas why I am getting a blank entry on the record that I add, but not on the record that I update?

Thanks

<%
On Error Resume Next

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
	Err.Clear

	Set fp_conn =  Server.CreateObject("ADODB.Connection")
	FP_DumpError strErrorUrl, "Cannot create connection"

	Set fp_rs = Server.CreateObject("ADODB.Recordset")
	FP_DumpError strErrorUrl, "Cannot create record set"

	fp_conn.Open Application("5y_ConnectionString")
	FP_DumpError strErrorUrl, "Cannot open database"

	fp_rs.Open "AllEdits", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
	FP_DumpError strErrorUrl, "Cannot open record set"

	fp_rs.AddNew
	FP_DumpError strErrorUrl, "Cannot add new record set to the database"
	Dim arFormFields0(15)
	Dim arFormDBFields0(15)
	Dim arFormValues0(15)

	arFormFields0(0) = "y5"
	arFormDBFields0(0) = "y5"
	arFormValues0(0) = Request("y5")
	arFormFields0(1) = "strUser"
	arFormDBFields0(1) = "User_name"
	arFormValues0(1) = Request("strUser")
	arFormFields0(2) = "strIncidentNum"
	arFormDBFields0(2) = "strIncidentNum"
	arFormValues0(2) = Request("strIncidentNum")
	arFormFields0(3) = "strName"
	arFormDBFields0(3) = "strName"
	arFormValues0(3) = Request("strName")
	arFormFields0(4) = "memProbStatement"
	arFormDBFields0(4) = "memProbStatement"
	arFormValues0(4) = Request("memProbStatement")
	arFormFields0(5) = "strModule"
	arFormDBFields0(5) = "strModule"
	arFormValues0(5) = Request("strModule")
	arFormFields0(6) = "strSolution"
	arFormDBFields0(6) = "strSolution"
	arFormValues0(6) = Request("strSolution")
	arFormFields0(7) = "ynEntered"
	arFormDBFields0(7) = "ynEntered"
	arFormValues0(7) = Request("ynEntered")
	arFormFields0(8) = "strUnit"
	arFormDBFields0(8) = "strUnit"
	arFormValues0(8) = Request("strUnit")
	arFormFields0(9) = "dtDate"
	arFormDBFields0(9) = "dtDate"
	arFormValues0(9) = Request("dtDate")
	arFormFields0(10) = "y1"
	arFormDBFields0(10) = "y1"
	arFormValues0(10) = Request("y1")
	arFormFields0(11) = "y2"
	arFormDBFields0(11) = "y2"
	arFormValues0(11) = Request("y2")
	arFormFields0(12) = "y3"
	arFormDBFields0(12) = "y3"
	arFormValues0(12) = Request("y3")
	arFormFields0(13) = "y4"
	arFormDBFields0(13) = "y4"
	arFormValues0(13) = Request("y4")
	arFormFields0(14) = "ynShared"
	arFormDBFields0(14) = "ynShared"
	arFormValues0(14) = Request("ynShared")

	FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

	FP_SaveFieldToDB fp_rs, Now, "Timestamp"

	fp_rs.Update
	FP_DumpError strErrorUrl, "Cannot update the database"

	fp_rs.Close
	fp_conn.Close

	Session("FP_SavedFields")=arFormFields0
	Session("FP_SavedValues")=arFormValues0
	

End If
End If

%>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
<meta name="Microsoft Theme" content="5whys 1000, default">
<meta name="Microsoft Border" content="t, default">
</head>

<body>

<p> </p>
<table width="100%" border="1">
  <thead>
  </thead>
  <tbody>
    <!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="Update Results SET dtDate=#::dtDate::#, strIncidentNum='::strIncidentNum::', strName='::strName::', strModule='::strModule::', strUnit='::strUnit::', memProbStatement='::memProbStatement::', y1='::y1::', y2='::y2::', y3='::y3::', y4='::y4::', y5='::y5::', strSolution='::strSolution::', ynShared='::ynShared::', ynEntered='::ynEntered::', User_name='::User_name::' WHERE ID=::ID::"
fp_sDefault="dtDate=&strIncidentNum=&strName=&strModule=&strUnit=&memProbStatement=&y1=&y2=&y3=&y4=&y5=&strSolution=&ynShared=&ynEntered=&User_name=&ID="
fp_sNoRecords="<tr><td colspan=16 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="5y"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->

    <!--#include file="_fpclass/fpdbrgn2.inc"-->

  </tbody>
</table>
</body>

</html>




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.054688E-02