18. juni 2001 - 19:43Der er
4 kommentarer og 2 løsninger
hvordan slettes en tom record!
Det handler om en record som der kan fyldes tekst ind i via et textfield! Hvis man sletter alt tekst i tekstfieldet skal hele den pågældende record også slettes. Hvordan gør jeg dette?
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
\' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, \"|\") MM_columns = Split(MM_columnsStr, \"|\")
\' set the form values For i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(i+1) = CStr(Request.Form(MM_fields(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 %> <% \' *** Update Record: construct a sql update statement and execute it
If (CStr(Request(\"MM_update\")) <> \"\" And CStr(Request(\"MM_recordId\")) <> \"\") Then
\' create the sql update statement MM_editQuery = \"update \" & MM_editTable & \" set \" For i = LBound(MM_fields) To UBound(MM_fields) Step 2 FormVal = MM_fields(i+1) MM_typeArray = Split(MM_columns(i+1),\",\") Delim = MM_typeArray(0) If (Delim = \"none\") Then Delim = \"\" AltVal = MM_typeArray(1) If (AltVal = \"none\") Then AltVal = \"\" EmptyVal = MM_typeArray(2) If (EmptyVal = \"none\") Then EmptyVal = \"\" If (FormVal = \"\") Then FormVal = EmptyVal Else If (AltVal <> \"\") Then FormVal = AltVal ElseIf (Delim = \"\'\") Then \' escape quotes FormVal = \"\'\" & Replace(FormVal,\"\'\",\"\'\'\") & \"\'\" Else FormVal = Delim + FormVal + Delim End If End If If (i <> LBound(MM_fields)) Then MM_editQuery = MM_editQuery & \",\" End If MM_editQuery = MM_editQuery & MM_columns(i) & \" = \" & FormVal Next MM_editQuery = MM_editQuery & \" where \" & MM_editColumn & \" = \" & MM_recordId
If (Not MM_abortEdit) Then \' execute the update 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 Journal__MMColParam Journal__MMColParam = \"1\" if (Request.QueryString(\"ID\") <> \"\") then Journal__MMColParam = Request.QueryString(\"ID\") %> <% set Journal = Server.CreateObject(\"ADODB.Recordset\") Journal.ActiveConnection = MM_connection_STRING Journal.Source = \"SELECT * FROM journal WHERE ID = \" + Replace(Journal__MMColParam, \"\'\", \"\'\'\") + \"\" Journal.CursorType = 0 Journal.CursorLocation = 2 Journal.LockType = 3 Journal.Open() Journal_numRows = 0 %> <% Dim journalnavn__MMColParam journalnavn__MMColParam = \"1\" if (Request.QueryString(\"ID\") <> \"\") then journalnavn__MMColParam = Request.QueryString(\"ID\") %> <% set journalnavn = Server.CreateObject(\"ADODB.Recordset\") journalnavn.ActiveConnection = MM_connection_STRING journalnavn.Source = \"SELECT * FROM hentjournalnavn WHERE ID = \" + Replace(journalnavn__MMColParam, \"\'\", \"\'\'\") + \"\" journalnavn.CursorType = 0 journalnavn.CursorLocation = 2 journalnavn.LockType = 3 journalnavn.Open() journalnavn_numRows = 0 %> <% \' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
\' create the list of parameters which should not be maintained MM_removeList = \"&index=\" If (MM_paramName <> \"\") Then MM_removeList = MM_removeList & \"&\" & MM_paramName & \"=\" MM_keepURL=\"\":MM_keepForm=\"\":MM_keepBoth=\"\":MM_keepNone=\"\"
\' add the URL parameters to the MM_keepURL string For Each Item In Request.QueryString NextItem = \"&\" & Item & \"=\" If (InStr(1,MM_removeList,NextItem,1) = 0) Then MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item)) End If Next
\' add the Form variables to the MM_keepForm string For Each Item In Request.Form NextItem = \"&\" & Item & \"=\" If (InStr(1,MM_removeList,NextItem,1) = 0) Then MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item)) End If Next
\' create the Form + URL string and remove the intial \'&\' from each of the strings MM_keepBoth = MM_keepURL & MM_keepForm if (MM_keepBoth <> \"\") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1) if (MM_keepURL <> \"\") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1) if (MM_keepForm <> \"\") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
\' a utility function used for adding additional parameters to these strings Function MM_joinChar(firstItem) If (firstItem <> \"\") Then MM_joinChar = \"&\" Else MM_joinChar = \"\" End If End Function %>
Tak, for hjælpen. Jeg tror jeg prøver s_raagaard svaret - det ser fornuftigt ud! Hvorfor bevare et tomt felt som aldrig skal bruges mere!
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.