Med version 7 af TeamShare tager Lector næste skridt og bygger en platform for AI-agenter, der i højere grad kan følge medarbejderen gennem hele arbejdsprocessen.
Nej, jeg har ikke lavet det med afkrydsningsfelterne. Jeg har en form men et søgefelt, og en anden side med søgeresultatet. Dette er lavet ud fra den artikel, der er nævnt længere oppe.
<% \' Henter værdien fra sidste side strKeywordForm = Trim(Request.Form(\"Keyword\")) If Len(strKeywordForm) = 0 Then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") Else \' Hvis der er skrevet i feltet strKeywordForm = Replace(strKeywordForm,\"\'\",\"\'\'\") End If
nFeltItems = Request.Form(\"felter\").Count If nFeltItems = 0 then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End If
for i = 1 to nFeltItems strKeyword = strKeywordForm indexToFirstWord = inStr (1,strKeyword, \" \") if indexToFirstWord > 0 then \'More then one search word FirstWord = mid(strKeyword,1,indexToFirstWord-1) strKeyword = Trim(mid(strKeyword,indexToFirstWord+1,len(strKeyword)-indexToFirstWord+1))
do startPos = Instr(1,strKeyword,\" \",1) slutPos = InStr (Cint(startPos)+1,strKeyword,\" \",1) if startPos > 0 then if slutPos = 0 then kopierTil = len(strKeyword)+1 else kopierTil = slutPos end if functionWord = mid(strKeyword,1,startPos-1) if slutPos=0 then searchWord = mid(strKeyword,startPos+1,len(strKeyword)-startPos) else searchWord = mid(strKeyword,startPos+1,slutPos-startPos) end if strKeyword = mid(strKeyword,kopierTil+1,len(strKeyword)-kopierTil+1) select case functionWord case \"OG\" strToSQL = strToSQL & \" AND \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & searchWord & \"%\'\" case \"ELLER\" strToSQL = strToSQL & \" OR \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & searchWord & \"%\'\" case \"IKKE\" \'?? hvordan end select else Response.Write (\"FEJL I INDTASTNING\") end if loop until (startPos = 0) or (slutPos = 0) else \'kun 1 søge ord. strToSQL = Request.Form(\"felter\")(i) & \" LIKE \'%\" & strKeyword & \"%\'\" end if
if i = 1 then strSQLWhere = \"(\" & strToSQL & \")\" else strSQLWhere = strSQLWhere & \" OR (\" & strToSQL & \")\" end if next
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\".\\db\\db5.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.RecordSet\") myConn.Open strDSN
strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere Set rs = myConn.Execute(strSQL) if not (rs.BOF and rs.EOF) then Response.Write \"<table>\" Response.Write \"<tr><td>ID</td><td>Emne</td><td>Vedr</td></tr>\" do while not rs.EOF Response.Write \"<tr>\" Response.Write \"<td>\" & rs(\"ID\") & \"</td>\" Response.Write \"<td>\" & rs(\"Emne\") & \"</td>\" Response.Write \"<td>\" & rs(\"Vedr\") & \"</td>\" Response.Write \"</tr>\" rs.MoveNext loop Response.Write \"</table>\" end if
myConn.Close Set myConn = Nothing %> </body> </html>
Jeg havde tænkt mig det sådan, at hvis du søgte på \"bil og hus\", så fandt den alle de poster, hvor både ordene bil og hus indgik på tværs af kolonnerne, men stadig i samme post.
<% \' Henter værdien fra sidste side strKeywordForm = Trim(Request.Form(\"Keyword\")) If Len(strKeywordForm) = 0 Then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") Else \' Hvis der er skrevet i feltet strKeywordForm = Replace(strKeywordForm,\"\'\",\"\'\'\") strKeywordForm = Replace(strKeywordForm,\" \",\" \") End If
nFeltItems = Request.Form(\"felter\").Count If nFeltItems = 0 then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End If
wordArray = Split(strKeywordForm,\" \",-1)
i = 1 firstTime = true lastFunctionWord = \"\" for wc = LBound(wordArray) to UBound(wordArray) if firstTime = true then firstTime = false strSQL = \"((\" & Request.Form(\"felter\")(1) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & \" OR \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" else if Ucase(wordArray(wc)) = \"OG\" then if lastFunctionWord = \"\" then lastFunctionWord = \"OG\" strSQL = strSQL & \" AND \" elseif lastFunctionWord = \"ELLER\" then lastFunctionWord = \"OG\" strSQL = strSQL & \") AND (\" else strSQL = strSQL & \" AND \" end if elseif Ucase(wordArray(wc)) = \"ELLER\" then if lastFunctionWord = \"\" then lastFunctionWord = \"ELLER\" strSQL = strSQL & \" OR \" elseif lastFunctionWord = \"OG\" then lastFunctionWord = \"ELLER\" strSQL = strSQL & \") OR (\" else strSQL = strSQL & \" OR \" end if else strSQL = strSQL & \"(\" & Request.Form(\"felter\")(1) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & \" OR \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" end if end if next strSQL = strSQL & \")\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\".\\db\\db5.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.RecordSet\") myConn.Open strDSN
strSQLWhere = strSQL strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere Response.Write \"<br>\" & strSQL & \"<br>\" Set rs = myConn.Execute(strSQL) if not (rs.BOF and rs.EOF) then Response.Write \"<table>\" Response.Write \"<tr><td>ID</td><td>Emne</td><td>Vedr</td></tr>\" do while not rs.EOF Response.Write \"<tr>\" Response.Write \"<td>\" & rs(\"ID\") & \"</td>\" Response.Write \"<td>\" & rs(\"Emne\") & \"</td>\" Response.Write \"<td>\" & rs(\"Vedr\") & \"</td>\" Response.Write \"</tr>\" rs.MoveNext loop Response.Write \"</table>\" end if
Det lyder sku godt. Du må meget gerne sende mig den. Jeg er meget taknemlig for din hjælp. Hvis det virker synes jeg bare vi skal stoppe her, for så er jeg meget tilfreds.
Hvad siger du til 300 point - er det nok for dit store arbejde??
300 ja tak det lyder fint :) Test lige og sig hvis der skal rettes noget jeg vil lige kikke vidre på den. Det er nogle problmmer hvis man blander for mange og/eller i samme linie (3 eller flere..bil og hus eller båd og ski), jeg ved ikke om det let kan løses men jeg tror det kan løses:
<% \' Henter værdien fra sidste side strKeywordForm = Trim(Request.Form(\"Keyword\")) If Len(strKeywordForm) = 0 Then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") Else \' Hvis der er skrevet i feltet strKeywordForm = Replace(strKeywordForm,\"\'\",\"\'\'\") strKeywordForm = Replace(strKeywordForm,\" \",\" \") End If
nFeltItems = Request.Form(\"felter\").Count If nFeltItems = 0 then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End If
wordArray = Split(strKeywordForm,\" \",-1)
i = 1 firstTime = true lastFunctionWord = \"\" for wc = LBound(wordArray) to UBound(wordArray) if firstTime = true then firstTime = false strSQL = \"((\" & Request.Form(\"felter\")(1) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & \" OR \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" else if Ucase(wordArray(wc)) = \"OG\" then if lastFunctionWord = \"\" then lastFunctionWord = \"OG\" strSQL = strSQL & \" AND \" elseif lastFunctionWord = \"ELLER\" then lastFunctionWord = \"OG\" strSQL = strSQL & \") AND (\" else strSQL = strSQL & \" AND \" end if elseif Ucase(wordArray(wc)) = \"ELLER\" then if lastFunctionWord = \"\" then lastFunctionWord = \"ELLER\" strSQL = strSQL & \" OR \" elseif lastFunctionWord = \"OG\" then lastFunctionWord = \"ELLER\" strSQL = strSQL & \") OR (\" else strSQL = strSQL & \" OR \" end if elseif Ucase(wordArray(wc)) = \"IKKE\" then strSQL = strSQL & \") AND (\" lastFunctionWord = \"IKKE\" else if lastFunctionWord = \"IKKE\" then str_NOT = \" NOT \" function_Word = \" AND \" else str_NOT = \"\" function_Word = \" OR \" end if strSQL = strSQL & \"(\" & Request.Form(\"felter\")(1) & str_NOT & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & function_Word & Request.Form(\"felter\")(i) & str_NOT & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" end if end if next strSQL = strSQL & \")\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\".\\db\\db5.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.RecordSet\") myConn.Open strDSN
strSQLWhere = strSQL strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere Response.Write \"<br>\" & strSQL & \"<br>\" Set rs = myConn.Execute(strSQL) if not (rs.BOF and rs.EOF) then Response.Write \"<table>\" Response.Write \"<tr><td>ID</td><td>Emne</td><td>Vedr</td></tr>\" do while not rs.EOF Response.Write \"<tr>\" Response.Write \"<td>\" & rs(\"ID\") & \"</td>\" Response.Write \"<td>\" & rs(\"Emne\") & \"</td>\" Response.Write \"<td>\" & rs(\"Vedr\") & \"</td>\" Response.Write \"</tr>\" rs.MoveNext loop Response.Write \"</table>\" end if
<% \' Henter værdien fra sidste side strKeywordForm = Trim(Request.Form(\"Keyword\")) If Len(strKeywordForm) = 0 Then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End if strKeywordForm = Replace(strKeywordForm,\"\'\",\"\'\'\") strKeywordForm = Replace(strKeywordForm,\" \",\" \")
nFeltItems = Request.Form(\"felter\").Count If nFeltItems = 0 then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End If wordArray = Split(strKeywordForm,\" \",-1)
firstTime = true lastFunctionWord = \"\" changeFunction = false for wc = LBound(wordArray) to UBound(wordArray) if firstTime = true then firstTime = false strSQL = \"((\" & Request.Form(\"felter\")(1) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & \" OR \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" else if Ucase(wordArray(wc)) = \"OG\" then if (lastFunctionWord = \"ELLER\") and (changeFunction = false) then lastFunctionWord = \"OG\" : strSQL = strSQL & \") AND (\" changeFunction = true else lastFunctionWord = \"OG\" strSQL = strSQL & \" AND \" changeFunction = false end if elseif Ucase(wordArray(wc)) = \"ELLER\" then if lastFunctionWord = \"OG\" and changeFunction = false then lastFunctionWord = \"ELLER\" strSQL = strSQL & \") OR (\" changeFunction = true else lastFunctionWord = \"ELLER\" strSQL = strSQL & \" OR \" changeFunction = false end if elseif Ucase(wordArray(wc)) = \"IKKE\" then strSQL = \"(\" & strSQL & \")\" strSQL = strSQL & \") AND (\" lastFunctionWord = \"IKKE\" else if lastFunctionWord = \"IKKE\" then str_NOT = \" NOT \" function_Word = \" AND \" else str_NOT = \"\" function_Word = \" OR \" end if strSQL = strSQL & \"(\" & Request.Form(\"felter\")(1) & str_NOT & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & function_Word & Request.Form(\"felter\")(i) & str_NOT & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" end if end if next strSQL = strSQL & \")\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\".\\db\\db5.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.RecordSet\") myConn.Open strDSN
strSQLWhere = strSQL strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere \'Response.Write \"<br>\" & strSQL & \"<br>\" Set rs = myConn.Execute(strSQL) if not (rs.BOF and rs.EOF) then Response.Write \"<table>\" Response.Write \"<tr><td>ID</td><td>Emne</td><td>Vedr</td></tr>\" do while not rs.EOF Response.Write \"<tr>\" Response.Write \"<td>\" & rs(\"ID\") & \"</td>\" Response.Write \"<td>\" & rs(\"Emne\") & \"</td>\" Response.Write \"<td>\" & rs(\"Vedr\") & \"</td>\" Response.Write \"</tr>\" rs.MoveNext loop Response.Write \"</table>\" end if
hvis du vil havde antal record skal du enten lave to SQL-sætninger eller åbne recordsetet på en anden måde:
To SQL sætninger:
countSQL = \"SELECT count(*) as antalFundet FROM tabel_navn WHERE \" & strSQLWhere strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere
Set rs = myConn.Execute(countSQL) Response.Write \"Antal fundet : \" & rs(\"antalFundet\")
Set rs = myConn.Execute(strSQL) if not (rs.BOF and rs.EOF) then Response.Write \"<table>\" Response.Write \"<tr><td>ID</td><td>Emne</td><td>Vedr</td></tr>\" do while not rs.EOF Response.Write \"<tr>\" Response.Write \"<td>\" & rs(\"ID\") & \"</td>\" Response.Write \"<td>\" & rs(\"Emne\") & \"</td>\" Response.Write \"<td>\" & rs(\"Vedr\") & \"</td>\" Response.Write \"</tr>\" rs.MoveNext loop Response.Write \"</table>\" end if myConn.Close Set myConn = Nothing
Åben recordset på anden måde:
strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere
if not (rs.BOF and rs.EOF) then Response.Write \"<table>\" Response.Write \"<tr><td>ID</td><td>Emne</td><td>Vedr</td></tr>\" do while not rs.EOF Response.Write \"<tr>\" Response.Write \"<td>\" & rs(\"ID\") & \"</td>\" Response.Write \"<td>\" & rs(\"Emne\") & \"</td>\" Response.Write \"<td>\" & rs(\"Vedr\") & \"</td>\" Response.Write \"</tr>\" rs.MoveNext loop Response.Write \"</table>\" end if rs.Close myConn.Close Set myConn = Nothing
det skal sættes ind her efter:
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\".\\db\\db5.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.RecordSet\") myConn.Open strDSN
<% \' Henter værdien fra sidste side strKeywordForm = Trim(Request.Form(\"Keyword\")) If Len(strKeywordForm) = 0 Then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End if strKeywordForm = Replace(strKeywordForm,\"\'\",\"\'\'\") strKeywordForm = Replace(strKeywordForm,\" \",\" \")
nFeltItems = Request.Form(\"felter\").Count If nFeltItems = 0 then \' Hvis der ikke er skrevet i feltet Response.Clear Response.Redirect(\"default.asp\") End If wordArray = Split(strKeywordForm,\" \",-1)
firstTime = true lastFunctionWord = \"\" changeFunction = false for wc = LBound(wordArray) to UBound(wordArray) if firstTime = true then firstTime = false strSQL = \"((\" & Request.Form(\"felter\")(1) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & \" OR \" & Request.Form(\"felter\")(i) & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" else if Ucase(wordArray(wc)) = \"OG\" then if (lastFunctionWord = \"ELLER\") and (changeFunction = false) then lastFunctionWord = \"OG\" : strSQL = strSQL & \") AND (\" changeFunction = true else lastFunctionWord = \"OG\" strSQL = strSQL & \" AND \" changeFunction = false end if elseif Ucase(wordArray(wc)) = \"ELLER\" then if lastFunctionWord = \"OG\" and changeFunction = false then lastFunctionWord = \"ELLER\" strSQL = strSQL & \") OR (\" changeFunction = true else lastFunctionWord = \"ELLER\" strSQL = strSQL & \" OR \" changeFunction = false end if elseif Ucase(wordArray(wc)) = \"IKKE\" then strSQL = \"(\" & strSQL & \")\" strSQL = strSQL & \") AND (\" lastFunctionWord = \"IKKE\" else if lastFunctionWord = \"IKKE\" then str_NOT = \" NOT \" function_Word = \" AND \" else str_NOT = \"\" function_Word = \" OR \" end if strSQL = strSQL & \"(\" & Request.Form(\"felter\")(1) & str_NOT & \" LIKE \'%\" & wordArray(wc) & \"%\'\" for i = 2 to nFeltItems strSQL = strSQL & function_Word & Request.Form(\"felter\")(i) & str_NOT & \" LIKE \'%\" & wordArray(wc) & \"%\'\" next strSQL = strSQL & \")\" end if end if next strSQL = strSQL & \")\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\".\\db\\db5.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.RecordSet\") myConn.Open strDSN
strSQLWhere = strSQL
\'\'\'\'countSQL = \"SELECT count(*) as antalFundet FROM tabel_navn WHERE \" & strSQLWhere \'strSQL = \"SELECT * FROM tabel_navn WHERE \" & strSQLWhere \'VIRKER
strSQL = \"SELECT *, tabel_navn.ID as tabelID \" strSQL = strSQL & \"FROM tabel_navn LEFT JOIN Handelsetekst ON tabel_navn.cpr = Handelsetekst.cpr\" strSQL = strSQL & \" WHERE \" & strSQLWhere
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.