The first thing to do is to debug the program and see on what operation the problem is occuring. If it is the execution of the SQL statement, check that you have provided all parameters correctly and the SQL statement looks as it should.
After that you can use profiler to investigate more, what happens during the execution of the statement. See
Monitoring with SQL Profiler[
^].