31. oktober 2008 - 20:37Der er
7 kommentarer og 2 løsninger
problem med InStr procedure
Jeg har nogle problemer med min InStr procedure. Den returnerer false, selvom den bør være true.
Jeg har følgende kodestykke:
'Foretag søgning i Adress hvis adresse er mere end inting if (Adress <> "") And (Adress <> "undefined") And oRec("adresse") <> "" then AdresseMatchPoint = cint(AdresseMatchPoint) Adress = Replace(Adress,".","") Adress = Trim(Replace(Adress,",","")) CompAdress = Replace(oRec("adresse"),".","") CompAdress = Trim(Replace(CompAdress,",","")) if (Instr(Adress,CompAdress) and CompAdress <> "") then cint(AdresseMatchPoint = 2) end if if ((Instr(Adress,trim(oRec("postnr"))) and trim(oRec("postnr")) <> "") Or (instr(Adress,trim(oRec("city"))) and trim(oRec("city")) <> "")) then AdresseMatchPoint = int(AdresseMatchPoint^2) end if if AdresseMatchPoint > 0 then AdresseMatchPoint = int(AdresseMatchPoint^2) result = result & "|" & oRec("Kid") & "," & AdresseMatchPoint resultSum = resultSum + AdresseMatchPoint AdresseFirmMatch = "true" end if end if
Jeg ser ikke hvad fejlen i mine inStr procedurer kan være? Hvis jeg prøver at kopiere en tekst fra min db og smide det ind istedet for oRec("adresse") returnerer den true i de tilfælde hvor den skal, men ellers ikke.
Denne side indeholder artikler med forskellige perspektiver på Identity & Access Management i private og offentlige organisationer. Artiklerne behandler aktuelle IAM-emner og leveres af producenter, rådgivere og implementeringspartnere.
'du skal passe på med at lave oRec("adresse") flere gange - nogle gange tager den den kun 1 første gang - det er bedre at lave en variabel med oRec 1 gang og så derefter arbejde med den/dem - her et eksempel
Adresse = oRec("adresse") Postnr = trim(oRec("postnr")) City = trim(oRec("city")) Kid = trim(oRec("city")) adresse_total = Adresse & Postnr & City adresse_total = replace(adresse_total,",""") adresse_total = replace(adresse_total,".","") if adresse_total <> "" then AdresseMatchPoint = 2 else AdresseMatchPoint = 0 end if if AdresseMatchPoint > 0 then AdresseMatchPoint = int(AdresseMatchPoint^2) result = result & "|" & Kid & "," & AdresseMatchPoint resultSum = resultSum + AdresseMatchPoint end if
'Foretag søgning i Adress hvis adresse er mere end inting if (Adress <> "") And (Adress <> "undefined") And oRec("adresse") <> "" then AdresseMatchPoint = cint(AdresseMatchPoint) Adress = Replace(Adress,".","") Adress = Trim(Replace(Adress,",","")) CompAdress = Replace(oRec("adresse"),".","") CompAdress = Trim(Replace(CompAdress,",","")) if (Instr(Adress,CompAdress) and CompAdress <> "") then cint(AdresseMatchPoint = 2) end if if ((Instr(Adress,trim(oRec("postnr"))) and trim(oRec("postnr")) <> "") Or (instr(Adress,trim(oRec("city"))) and trim(oRec("city")) <> "")) then AdresseMatchPoint = int(AdresseMatchPoint^2) end if if AdresseMatchPoint > 0 then AdresseMatchPoint = int(AdresseMatchPoint^2) result = result & "|" & oRec("Kid") & "," & AdresseMatchPoint resultSum = resultSum + AdresseMatchPoint AdresseFirmMatch = "true" end if end if
men det du har skrevet gør ikke det som jeg vil opnå. Den indeholder ingen strengsøgning.
if (Adress <> "") And (Adress <> "undefined") And CompAdress <> "" then AdresseMatchPoint = cint(AdresseMatchPoint) Adress = Replace(Adress,".","") Adress = Trim(Replace(Adress,",","")) CompAdress = Replace(oRec("adresse"),".","") CompAdress = Trim(Replace(CompAdress,",","")) AddrPostNr = trim(oRec("postnr")) AddrCity = trim(oRec("city")) if (Instr(Adress,CompAdress) and CompAdress <> "") then cint(AdresseMatchPoint = 2) end if if ((Instr(Adress, AddrPostNr) and AddrPostNr <> "") Or (instr(Adress, AddrCity) and AddrCity <> "")) then AdresseMatchPoint = int(AdresseMatchPoint^2) end if if AdresseMatchPoint > 0 then AdresseMatchPoint = int(AdresseMatchPoint^2) result = result & "|" & oRec("Kid") & "," & AdresseMatchPoint resultSum = resultSum + AdresseMatchPoint AdresseFirmMatch = "true" end if end if
nej - men hvis du vil søge i en streng skal du hente det hele i db først til strengen og derefter søge.. hvor gør du lige dette - Hvis jeg prøver at kopiere en tekst fra min db og smide det ind istedet for oRec("adresse") returnerer den true i de tilfælde hvor den skal, men ellers ikke.
mit problem er imidlertid egentlig at jeg har mærkelig tegnsætnign med Æ, Ø, Å og dets lige. Jeg har angivet
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> og <%response.Charset="UTF-8"%>
i firefox betyder det at alle tegn bliver vist korrekt inden jeg behandler med ASP, hvor æ Æ vises forkert, men i IE bliver alle Æ Ø Å vist forkert på alle tidspunkter ex. æ = æ
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.