0

I'm trying to trying to get this query to work:

  HttpWebRequest request = WebRequest.Create("&query=select * from person limit1")
  as HttpWebRequest;

but what i need to do for that is put %20 for ever space like this:

HttpWebRequest request = WebRequest.Create( 
"&query=select%20*%20from%20person%20limit%201") 
as HttpWebRequest;

but i want to do that automaticly and read that Uri.EscapeUriString was the best way to do that but i don't know how to implement that.

I hope you guys can help.

Kale
  • 67
  • 5
  • so are you trying to replace spaces with `%20` ? – Amit Joki Mar 18 '14 at 15:17
  • 1
    Be very careful when accepting raw sql as part of a query string - you are supremely vulnerable to SQL Injection (see http://stackoverflow.com/questions/601300/what-is-sql-injection). EscapeUriString is a static method on the URI class. However, I believe your question is already answered here: http://stackoverflow.com/questions/1517586/how-do-i-replace-all-the-spaces-with-20-in-c-sharp – dash Mar 18 '14 at 15:19

1 Answers1

2

Like this?:

WebRequest.Create(Uri.EscapeUriString("&query=select * from person limit1"))

Or am I missing something?

David
  • 176,566
  • 33
  • 178
  • 245