台灣最大程式設計社群網站
線上人數
1320
 
會員總數:246141
討論主題:189725
歡迎您免費加入會員
討論區列表 >> ASP >> 執行表單刪除資料時,可以順便將表單資料寫入Log資料庫
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
執行表單刪除資料時,可以順便將表單資料寫入Log資料庫
價值 : 210 QP  點閱數:466 回應數:7
樓主

Peter
門外漢
0 1
30 4
發送站內信

需求 執行表單刪除資料時,可以順便將表單資料寫入Log資料庫

<%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>
<!--#include file="../Connections/oa.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) = "delete" And CStr(Request("MM_recordId")) <> "") Then

If (Not MM_abortEdit) Then
' execute the delete
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_oa_STRING
MM_editCmd.CommandText = "DELETE FROM dbo.asset WHERE Asset_Number = ?"
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 200, 1, 255, Request.Form("MM_recordId")) ' adVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "oa_modify.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If

End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("Asset_Number") <> "") Then
Recordset1__MMColParam = Request.QueryString("Asset_Number")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_oa_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.asset WHERE Asset_Number = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 255, Recordset1__MMColParam) ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>無標題文件</title>
<style type="text/css">
.auto-style1 {
border: 2px solid #000000;
background-color: #FFFF99;
}
.auto-style2 {
white-space: normal;
border-style: solid;
border-width: 2px;
}
.auto-style3 {
border-style: solid;
border-width: 2px;
}
.auto-style4 {
border-style: solid;
}
.auto-style5 {
font-size: x-large;
font-weight: bold;
}
.auto-style6 {
border-width: 2px;
}
.auto-style7 {
white-space: normal;
border-width: 2px;
}
.auto-style9 {
white-space: normal;
border-bottom-style: solid;
border-bottom-width: 2px;
text-align: center;
font-size: large;
}
</style>
</head>

<body style="background-color: #FFFFCC">
<div align="center">
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="delete" id="delete">
<p class="auto-style5">&nbsp;</p>
<table align="center" class="auto-style1">
<tr valign="baseline">
<td class="auto-style9" colspan="2">刪除紀錄</td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">資 產 編 號</td>
<td class="auto-style3"><a href="oa_modify.asp?Asset_Number=<%=(Recordset1.Fields.Item("Asset_Number").Value)%>"><%=(Recordset1.Fields.Item("Asset_Number").Value)%></a></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">品&nbsp;&nbsp;&nbsp; 名</td>
<td class="auto-style3">
<input type="text" name="Product" value="<%=(Recordset1.Fields.Item("Product").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">規格/型號</td>
<td class="auto-style3">
<input type="text" name="Model" value="<%=(Recordset1.Fields.Item("Model").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">保管人部門 </td>
<td class="auto-style3">
<input type="text" name="Holed_Unit" value="<%=(Recordset1.Fields.Item("Holed_Unit").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">保 管 人</td>
<td class="auto-style3">
<input type="text" name="Holder" value="<%=(Recordset1.Fields.Item("Holder").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">英 文 名 字</td>
<td class="auto-style3">
<input type="text" name="En_Name" value="<%=(Recordset1.Fields.Item("En_Name").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">存放區域</td>
<td class="auto-style3">
<input type="text" name="Location" value="<%=(Recordset1.Fields.Item("Location").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">IP_Address</td>
<td class="auto-style3">
<input type="text" name="IP_Address" value="<%=(Recordset1.Fields.Item("IP_Address").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">Mac_Address</td>
<td class="auto-style3">
<input type="text" name="Mac_Address" value="<%=(Recordset1.Fields.Item("Mac_Address").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">Net_Number</td>
<td class="auto-style3">
<input type="text" name="Net_Numbet" value="<%=(Recordset1.Fields.Item("Net_Numbet").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">備&nbsp;&nbsp;&nbsp; 註</td>
<td class="auto-style3">
<input type="text" name="Remark" value="<%=(Recordset1.Fields.Item("Remark").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style7" style="height: 25px"></td>
<td class="auto-style6" style="height: 25px">
<input name="delete" type="submit" id="delete" value="刪除紀錄"></td>
</tr>
</table>
<input type="hidden" name="MM_delete" value="delete">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("Asset_Number").Value %>">
</form>
<p>&nbsp;</p>
</div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>




搜尋相關Tags的文章: [ ASP ] , [ 資料庫 ] ,
本篇文章發表於2019-06-25 14:37
1樓
作者回應

Peter
檢舉此回應
加了寫入資料庫都沒反應

<%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>
<!--#include file="../Connections/oa.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) = "delete" And CStr(Request("MM_recordId")) <> "") Then

If (Not MM_abortEdit) Then
' execute the delete
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_oa_STRING
MM_editCmd.CommandText = "DELETE FROM dbo.asset WHERE Asset_Number = ?"
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 200, 1, 255, Request.Form("MM_recordId")) ' adVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close


Set MM_editCmd2 = Server.CreateObject ("ADODB.Command")
MM_editCmd2.ActiveConnection = MM_oa_STRING
MM_editCmd2.CommandText = "INSERT INTO dbo.asset_log (Asset_Number, Product, Model, Holed_Unit, Holder, En_Name, Location, IP_Address, Mac_Address, Net_Numbet, Remark,status,date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,'新增',getdate())"
MM_editCmd2.Prepared = true
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Asset_Number")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Product")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Model")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("select")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Holder")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("En_Name")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 255, Request.Form("Location")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 255, Request.Form("IP_Address")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 255, Request.Form("Mac_Address")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("Net_Numbet")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("Remark")) ' adVarWChar

MM_editCmd2.Execute
MM_editCmd2.ActiveConnection.Close
本篇文章回覆於2019-06-25 14:41
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
2樓
回應

小魚
檢舉此回應
不是應該要有 ADODB.Connection
而且你的 MM_oa_STRING 好像沒有定義?
正常這個位置應該是放 ADODB.Connection
本篇文章回覆於2019-06-25 17:22
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
3樓
作者回應

Peter
檢舉此回應
這是另外一個網頁 (當表單送出時,會寫入資料庫並且也會相同值到Log資料庫)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/oa.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' *** Redirect if username exists
MM_flag = "MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
Dim MM_rsKey
Dim MM_rsKey_cmd

MM_dupKeyRedirect = "oa_error1.asp"
MM_dupKeyUsernameValue = CStr(Request.Form("Asset_Number"))
Set MM_rsKey_cmd = Server.CreateObject ("ADODB.Command")
MM_rsKey_cmd.ActiveConnection = MM_oa_STRING
MM_rsKey_cmd.CommandText = "SELECT Asset_Number FROM dbo.asset WHERE Asset_Number = ?"
MM_rsKey_cmd.Prepared = true
MM_rsKey_cmd.Parameters.Append MM_rsKey_cmd.CreateParameter("param1", 200, 1, 255, MM_dupKeyUsernameValue) ' adVarChar
Set MM_rsKey = MM_rsKey_cmd.Execute
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")

MM_editCmd.ActiveConnection = MM_oa_STRING
MM_editCmd.CommandText = "INSERT INTO dbo.asset (Asset_Number, Product, Model, Holed_Unit, Holder, En_Name, Location, IP_Address, Mac_Address, Net_Numbet, Remark) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Asset_Number")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Product")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Model")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("select")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Holder")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("En_Name")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 255, Request.Form("Location")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 255, Request.Form("IP_Address")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 255, Request.Form("Mac_Address")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("Net_Numbet")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("Remark")) ' adVarWChar
MM_editCmd.Execute

Set MM_editCmd2 = Server.CreateObject ("ADODB.Command")
MM_editCmd2.ActiveConnection = MM_oa_STRING
MM_editCmd2.CommandText = "INSERT INTO dbo.asset_log (Asset_Number, Product, Model, Holed_Unit, Holder, En_Name, Location, IP_Address, Mac_Address, Net_Numbet, Remark,status,date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,'新增',getdate())"
MM_editCmd2.Prepared = true
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Asset_Number")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Product")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Model")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("select")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Holder")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("En_Name")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 255, Request.Form("Location")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 255, Request.Form("IP_Address")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 255, Request.Form("Mac_Address")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("Net_Numbet")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("Remark")) ' adVarWChar

MM_editCmd2.Execute
MM_editCmd2.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "oa_modify.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_oa_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.asset"
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<style type="text/css">
body,td,th {
font-size: 16px;
}
.auto-style7 {
border-width: 1px;
}
.auto-style8 {
border: 1px solid #000000;
background-color: #FFFF99;
}
.auto-style10 {
border-style: solid;
font-size: medium;
border-width: 1px;
font-weight: bold;
background-color: #FFFF99;
}
.auto-style12 {
border-style: solid;
font-size: large;
border-width: 1px;
background-color: #FFFF99;
text-align: center;
}
.auto-style13 {
border-style: solid;
}
.auto-style15 {
border-style: solid;
border-width: 1px;
background-color: #FFFF99;
}
.auto-style16 {
background-color: #FFFF99;
}
.auto-style17 {
border-style: solid;
font-size: medium;
border-width: 1px;
background-color: #FFFF99;
}
</style>
</head>

<body style="background-color: #FFFFCC">
<div align="center">
<p>&nbsp;</p>
<form action="<%=MM_editAction%>" method="POST" name="form1" id="form1">
<table align="center" class="auto-style16" >
<tr valign="baseline">
<td class="auto-style7">
<table align="center" cellpadding="2" class="auto-style8">
<tr valign="baseline">
<td class="auto-style12" colspan="2" style="height: 32">新增資料</td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">資 產 編 號</div></td>
<td class="auto-style15">
<input type="text" name="Asset_Number" value="" size="32" class="auto-style13"/></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">品&nbsp;&nbsp;&nbsp; 名</div></td>
<td class="auto-style15" >
<input type="text" name="Product" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td class="auto-style17" style="height: 27px"><div align="center">規格/型號</div></td>
<td class="auto-style15" style="height: 27px">
<input type="text" name="Model" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">保管人部門 </div></td>
<td class="auto-style15" >
<select name="select" id="select" class="auto-style13">
<option value="管理部">管理部</option>
<option value="運維部">運維部</option>
<option value="開發維運部">開發維運部</option>
<option value="平台部">平台部</option>
<option value="EO">EO</option>
<option value="EO新事業部">EO新事業部</option>
<option value="專案開發1部">專案開發1部</option>
<option value="專案開發2部">專案開發2部</option>
<option value="財務部">財務部</option>
<option value="國際部風控">國際部風控</option>
<option value="國際部商務">國際部商務</option>
</select></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">保 管 人</div></td>
<td class="auto-style15">
<input type="text" name="Holder" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">英 文 名 字</div></td>
<td class="auto-style15">
<input type="text" name="En_Name" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">存放區域</div></td>
<td class="auto-style15">
<input type="text" name="Location" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">IP_Address</div></td>
<td class="auto-style15" >
<input type="text" name="IP_Address" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">Mac_Address</div></td>
<td class="auto-style15">
<input type="text" name="Mac_Address" value="" size="32" class="auto-style13"/></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">Net_Number</div></td>
<td class="auto-style15">
<input name="Net_Numbet" type="text" class="auto-style13" id="Net_Numbet" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style17"><div align="center">備&nbsp;&nbsp;&nbsp;&nbsp; 註</div></td>
<td class="auto-style15">
<input type="text" name="Remark" value="" size="32" class="auto-style13" /></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style10"><div align="center"></div></td>
<td class="auto-style15">
<input type="submit" value="插入記錄" style="height: 27px" class="auto-style13" /></td>
</tr>
</table></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
本篇文章回覆於2019-06-25 18:23
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
4樓
作者回應

Peter
檢舉此回應
這是刪除網頁 當表單送出時,會刪除這筆資料
但是我想要在裡面加入 在寫入一份相同值到log資料庫

<%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>
<!--#include file="../Connections/oa.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) = "delete" And CStr(Request("MM_recordId")) <> "") Then

If (Not MM_abortEdit) Then
' execute the delete
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_oa_STRING
MM_editCmd.CommandText = "DELETE FROM dbo.asset WHERE Asset_Number = ?"
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 200, 1, 255, Request.Form("MM_recordId")) ' adVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "oa_modify.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If

End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("Asset_Number") <> "") Then
Recordset1__MMColParam = Request.QueryString("Asset_Number")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_oa_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.asset WHERE Asset_Number = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 255, Recordset1__MMColParam) ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>無標題文件</title>
<style type="text/css">
.auto-style1 {
border: 2px solid #000000;
background-color: #FFFF99;
}
.auto-style2 {
white-space: normal;
border-style: solid;
border-width: 2px;
}
.auto-style3 {
border-style: solid;
border-width: 2px;
}
.auto-style4 {
border-style: solid;
}
.auto-style5 {
font-size: x-large;
font-weight: bold;
}
.auto-style6 {
border-width: 2px;
}
.auto-style7 {
white-space: normal;
border-width: 2px;
}
.auto-style9 {
white-space: normal;
border-bottom-style: solid;
border-bottom-width: 2px;
text-align: center;
font-size: large;
}
</style>
</head>

<body style="background-color: #FFFFCC">
<div align="center">
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="delete" id="delete">
<p class="auto-style5">&nbsp;</p>
<table align="center" class="auto-style1">
<tr valign="baseline">
<td class="auto-style9" colspan="2">刪除紀錄</td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">資 產 編 號</td>
<td class="auto-style3"><a href="oa_modify.asp?Asset_Number=<%=(Recordset1.Fields.Item("Asset_Number").Value)%>"><%=(Recordset1.Fields.Item("Asset_Number").Value)%></a></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">品&nbsp;&nbsp;&nbsp; 名</td>
<td class="auto-style3">
<input type="text" name="Product" value="<%=(Recordset1.Fields.Item("Product").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">規格/型號</td>
<td class="auto-style3">
<input type="text" name="Model" value="<%=(Recordset1.Fields.Item("Model").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">保管人部門 </td>
<td class="auto-style3">
<input type="text" name="Holed_Unit" value="<%=(Recordset1.Fields.Item("Holed_Unit").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">保 管 人</td>
<td class="auto-style3">
<input type="text" name="Holder" value="<%=(Recordset1.Fields.Item("Holder").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">英 文 名 字</td>
<td class="auto-style3">
<input type="text" name="En_Name" value="<%=(Recordset1.Fields.Item("En_Name").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">存放區域</td>
<td class="auto-style3">
<input type="text" name="Location" value="<%=(Recordset1.Fields.Item("Location").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">IP_Address</td>
<td class="auto-style3">
<input type="text" name="IP_Address" value="<%=(Recordset1.Fields.Item("IP_Address").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">Mac_Address</td>
<td class="auto-style3">
<input type="text" name="Mac_Address" value="<%=(Recordset1.Fields.Item("Mac_Address").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">Net_Number</td>
<td class="auto-style3">
<input type="text" name="Net_Numbet" value="<%=(Recordset1.Fields.Item("Net_Numbet").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style2">備&nbsp;&nbsp;&nbsp; 註</td>
<td class="auto-style3">
<input type="text" name="Remark" value="<%=(Recordset1.Fields.Item("Remark").Value)%>" size="32" class="auto-style4"></td>
</tr>
<tr valign="baseline">
<td align="right" class="auto-style7" style="height: 25px"></td>
<td class="auto-style6" style="height: 25px">
<input name="delete" type="submit" id="delete" value="刪除紀錄"></td>
</tr>
</table>
<input type="hidden" name="MM_delete" value="delete">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("Asset_Number").Value %>">
</form>
<p>&nbsp;</p>
</div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
本篇文章回覆於2019-06-25 18:25
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
5樓
回應

小魚
檢舉此回應
那就模仿他的語法寫就可以了,
我不知道你的問題在哪裡...
本篇文章回覆於2019-06-26 17:14
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
6樓
作者回應

Peter
檢舉此回應
我模仿他的與法但無法讓我寫入log資料庫
我在刪除資料表單中加入下列語法,都只讓我刪除資料筆數不讓我寫入log資料庫,是欄位值有問題嗎

Set MM_editCmd2 = Server.CreateObject ("ADODB.Command")
MM_editCmd2.ActiveConnection = MM_oa_STRING
MM_editCmd2.CommandText = "INSERT INTO dbo.asset_log (Asset_Number, Product, Model, Holed_Unit, Holder, En_Name, Location, IP_Address, Mac_Address, Net_Numbet, Remark,status,date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,'新增',getdate())"
MM_editCmd2.Prepared = true
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Asset_Number")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Product")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Model")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("select")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Holder")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("En_Name")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 255, Request.Form("Location")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 255, Request.Form("IP_Address")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 255, Request.Form("Mac_Address")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("Net_Numbet")) ' adVarWChar
MM_editCmd2.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("Remark")) ' adVarWChar

MM_editCmd2.Execute
MM_editCmd2.ActiveConnection.Close
本篇文章回覆於2019-06-27 09:57
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
7樓
最有價值解答

老頑童
捐贈 VP 給 老頑童 檢舉此回應
建議將 MM_editCmd.CreateParameter改成 MM_editCmd2.CreateParameter
因為你在前面己將MM_editCmd.ActiveConnection.Close
這邊再來用MM_editCmd可能有問題
(有成功寫入Log的那頁並沒有執行Close)
或是將MM_editCmd.ActiveConnection.Close移到後面再執行
本篇文章回覆於2019-06-28 09:48
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.