Ok, thanks. I see error of my ways now.
After Nishant Sivakumar suggested stored procedures as solution for the problem, I did some reading on the internet, so if you have the same problem as I did (once upon the time) and you are used to C# and/or VB but know only vary basics of databases and SQL, here is what I think to be usefull for you to read:
http://databases.about.com/od/sqlserver/a/storedprocedure.htm[
^]
to get the basic idea what is stored procedure and why to use it, and not query, than
http://www.sql-server-performance.com/articles/dba/stored_procedures_basics_p1.aspx[
^]
to cover the topic in more detail, and finaly
http://www.csharpfriends.com/articles/getarticle.aspx?articleid=78[
^]
to learn how to call your stored procedures from C# code.
Thanks again for help.