netcracker Posted January 10, 2006 Share Posted January 10, 2006 I need to do a search on a db but the string contains characters like &.Say, i search for "M&M" ... the result will be an error because of that character.How do I get the values with &, and how do I do the searh ?in my case i get the value by querystring, so i think i need to convert that character to something else... but what and how !?Anyone stumbled upon that before ?!THX Link to comment Share on other sites More sharing options...
aspnetguy Posted January 10, 2006 Share Posted January 10, 2006 What type of database are you using? I just did this query on a SQL Server DB and didn't get an error. SELECT ColumnNameFROM TableNameWHERE CHARINDEX('&',ColumnToSearch) > 0 Link to comment Share on other sites More sharing options...
netcracker Posted January 10, 2006 Author Share Posted January 10, 2006 it's a MS Acces DB... so far.It may eventualy go on a SQL server but it is not certain yet.So far, on my IIS it returns an error.it is expected though... i mean look at the link: whole path/file.asp?word=M&Mthe server is confused... Link to comment Share on other sites More sharing options...
aspnetguy Posted January 10, 2006 Share Posted January 10, 2006 okay, I see the problem. The problem is the browser is having trouble with the Querystring. '&' is a delimiter in querystrings (?var1=value1&var2=value2) so you cannot use it in this way. What you could do before you send the querystring is replace '&' with another character or group of characters (eg M:and:M)Then when it gets to the next page change it back by replacing :and: with & just before you do the DB query. Link to comment Share on other sites More sharing options...
netcracker Posted January 10, 2006 Author Share Posted January 10, 2006 THX everyone !I managed to solved it by server.URLencode(rs.fields.item("blabla"))and then everything went well.thanks a lot Link to comment Share on other sites More sharing options...
aspnetguy Posted January 10, 2006 Share Posted January 10, 2006 glad you worked it out! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now