[此贴子已经被作者于2005-8-25 16:55:26编辑过]
[此贴子已经被作者于2005-8-25 16:55:26编辑过]
set conn=server.createobject("adodb.connection") 这句里面的conn你换个名称试试吧!我知道你是Access数据库! 这是我在用的一个人员添加的原代码,只是一部分,也不知道对你有用不!反正发出来看看哈!研究研究!!观注这帖的结果! 下面是添加部分: <%
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 call fnCreateLog("添加新员工") If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End If
End If %> 下面是提交页面: <script>
if(!confirm("新增员工成功.\n您是否要继续添加新员工?")){ window.opener.location.reload() self.close() } else{ window.location.href="AddNew.asp" '添加成功,如选择继续添加新员工则返回AddNew.asp继续添加 }
</script> 我的也是Access数据库做的!
[此贴子已经被作者于2005-8-25 5:18:54编辑过]