'============================================================================== Public Function save_record_*[TableName]*() cDebug "6save_record_*[TableName]*()", "===[ " & Request.ServerVariables("PATH_INFO") & " ]===" Dim sCMD, objConn, objCmd, objParam '-------------------------------------------------------------------------- ' Table Name: *[TableName]* ' DB Path: *[DBPath]* ' Created by: Private Function getSaveCommand(sTableName, sDBPath), found in DBFunc.asp ' On: *[Date]* '-------------------------------------------------------------------------- if request("*[RecID]*") <> "" then '---[ Exsiting record. Use UPDATE command ]--- *[Update]* else '---[ New record! Use INSERT command ]--- *[Insert]* end if 'cDebug "sCMD",sCMD set objConn = Server.CreateObject("ADODB.Connection") objConn.Open application("DBDriver") & MapPath(application("MainDB")) Set objCmd = Server.CreateObject("ADODB.Command") objCmd.CommandText = sCMD objcmd.ActiveConnection = objConn objCmd.CommandType = adCmdText *[Parameters]* cDebug "ObjCmd",ObjCmd '---[ Uncomment the next line after confirming all configurations are valid ]--- 'on error resume next ' ObjCmd.Execute ' if err.number <> 0 then ' cDebug "ERROR!", err.Description & "(" & err.number & ")" ' end if 'on error goto 0 if request("*[RecID]*")="" then '---[ New record! Get the "*[RecID]*" of the INSERT'ed record ]----------- Dim oRecSet set oRecSet = Server.CreateObject("ADODB.Recordset") oRecSet.open "SELECT @@IDENTITY", objConn, adOpenStatic, adLockReadOnly, adCmdText oConfig("*[RecID]*") = oRecSet.Fields(0).value else '---[ Existing record. Get "*[RecID]*" from the request object ]---------- oConfig("*[RecID]*") = request("*[RecID]*") end if set objCmd = nothing set objConn = nothing cDebug "5save_record_*[TableName]*()", "===[ " & Request.ServerVariables("PATH_INFO") & " ]===" 'response.end End Function '==============================================================================