Parameterized Database Query

See this thread were I asked about database looping as well and here the solution provided by Tobias.