title: .NET/C# check if SQL query modifies database and if not execute
body: <p>I know how to execute queries from C# but I want to provide a dropdown list in which people can write a query and it will execute and populate the list.</p>
  
  <p>A problem is that I want to forbid all queries that modify the database in any way. I have not managed to find a way to do this and I did my best with google.</p>
  
  <p>The solution I can think of is that I will scan the query for INSERT, DELETE, UPDATE and only allow SELECT statements. However, I want to be able to allow users to call stored procedures as well. This means I need to get the body of the stored procedure and scan it before I execute it. How do I download a stored procedure then?</p>
  
  <p>If anyone knows a way to only execute read only queries do share please! I have the feeling scanning the text for INSERT, DELETE, UPDATE doesn't prevent SQL injections.</p>