标题:DREAMweaver中操作Acess表问题
只看楼主
zhaoxing359
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-28
 问题点数:0 回复次数:5 
DREAMweaver中操作Acess表问题
用Dreamweaver做了一个仓储页,access数据库中有一个表是存放现有库存备件名称、数量的,另一个为领用记录表。当领用备件时既要插入领用记录表,又要将现有库存备件表的备件数量进行更新,代码该怎样处理????
搜索更多相关主题的帖子: DREAMweaver Acess Dreamweaver 数据库 库存 
2007-04-13 13:29
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
得分:0 
操作两个表不就行了,这个是属于脚本语言的事
2007-04-13 17:57
zhaoxing359
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-28
得分:0 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/bjdata.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
dim sl
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
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form3") Then

MM_editConnection = MM_bjdata_STRING
MM_editTable = "bjly"
MM_editRedirectUrl = "sucessfull.asp"
MM_fieldsStr = "textfield3|value|textfield4|value|ly|value|textfield5|value|textfield2|value|ID|value"
MM_columnsStr = "名称|',none,''|规格|',none,''|数量|none,none,NULL|单位|',none,''|领用人|',none,''|序号|none,none,NULL"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

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

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

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

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_bjdata_STRING
Recordset1.Source = "SELECT * FROM bj WHERE ID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_bjdata_STRING
Recordset2.Source = "SELECT * FROM lyjl"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="teee.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style3 {
font-size: 20%;
background-color: #CCCCCC;
}
.style4 {
color: #0080FF;
font-size: 24px;
}
.zhao {
color: #FF0000;
background-color: #FFFFFF;
width: 80%;
}
.style5 {
color: #FF0000;
width: 80%;
background-color: #FFFFFF;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body bgcolor="#CCFFCC" text="#666600" link="#009900" vlink="#006600" alink="#00FF00">
<form name="form3" method="POST" action="<%=MM_editAction%>">

<p align="center" class="style4">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="391" height="33">
<param name="BGCOLOR" value="">
<param name="movie" value="text2.swf">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<embed src="text2.swf" width="391" height="33" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" ></embed>
</object>
</p>
<table width="90%" height="60" border="1" align="center" bgcolor="#669966" class="text">
<tr bordercolor="#000033" bgcolor="#FFFFFF">
<th width="16%" height="32" bordercolor="#000033" bgcolor="#FFFFFF" scope="col">名称</th>
<th width="22%" bordercolor="#000033" bgcolor="#FFFFFF" scope="col">规格</th>
<th width="6%" bordercolor="#000033" bgcolor="#FFFFFF" scope="col">库存数量</th>
<th width="10%" bordercolor="#000033" bgcolor="#FFFFFF" scope="col">领用数量</th>
<th width="3%" scope="col">单位</th>
<th width="10%" bordercolor="#000033" bgcolor="#FFFFFF" scope="col">领用人</th>
</tr>
<tr bordercolor="#000033" bgcolor="#FFFFFF">
<td width="16%" height="20" bordercolor="#000033" bgcolor="#FFFFFF">
<input name="textfield3" type="text" class="text" value="<%=(Recordset1.Fields.Item("名称").Value)%>" readonly="true"></td>
<td width="18%" bordercolor="#000033" bgcolor="#FFFFFF"> <input name="textfield4" type="text" class="text" value="<%=(Recordset1.Fields.Item("规格").Value)%>" readonly="true"></td>
<td width="6%" bordercolor="#000033" bgcolor="#FFFFFF"><span class="style3">
<input name="kc" type="text" class="text" id="kc" value="<%=(Recordset1.Fields.Item("数量").Value)%>" readonly="true">
</span></td>
<td width="10%" bordercolor="#000033" bgcolor="#FFFFFF"> <input name="ly" type="text" class="style5" id="ly" onBlur="MM_validateForm('textfield','','RisNum');return document.MM_returnValue""align="centrer"数量');return document.MM_returnValue></td>
<td width="3%">
<input name="textfield5" type="text" class="text" value="<%=(Recordset1.Fields.Item("单位").Value)%>" align="middle" border="0"></td>
<td width="10%" bordercolor="#000033" bgcolor="#FFFFFF">
<input name="textfield2" type="text" class="style5" border="0"> </td>
</tr>
</table>
<div align="center">
<p>&nbsp;</p>
<p align="center" class="text">
<input name="Submit2" type="submit" value="提交" width="30">    
<input type="reset" name="Submit" value="重置">
</p>
</div>

<input type="hidden" name="MM_insert" value="form3">
<label>
<input name="ID" type="hidden" value="<%=(Recordset1.Fields.Item("ID").Value)%>">
</label>
</form>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
请教我得从何处修改代码,才能实现从库存表数量中减去当前领用的数量??
2007-04-14 13:17
风月_无边
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:60
帖 子:2959
专家分:652
注 册:2007-1-19
得分:0 
晕,这么多的代码。同时对两个表操作就可以了 。

我的网站 http://www.
2007-04-14 18:20
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
得分:0 
哈哈,代码太长了,没法看!!

不过看到好多 MM
2007-04-14 21:30
kidy2005
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2007-4-18
得分:0 
你在两个表格之间建立联系,同时对两个表格进行操作啊,写这么多代码也没什么用啊

恒天装饰网:http://www.
2007-04-23 15:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-131580-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.801289 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved