Is there a way to execute sql on MS SQL Server from code in C#/VB.Net and guarantee that data wouldn't be changed? I need only loading data, but can't be sure that sql expression wouldn't contain insert/update/delete statement. I've tried SqlDataAdapter and SqlCommand.ExecuteReader(), but they allow modifying data. I understand that program just sends command to sql server and doesn't check it. The one option I see now is to use connection with read-only user. It will require very few changes in code. But it's not completely save, because connection string stored in config file and can be easily changed (and I cannot use hardcoded values). Some more complex way is to parse sql to check if it is actually query. I am not sure if there is some ready and reliable solution for it.
Is there any way to prevent running sql that can modify data from code?