These problems look like they may have to do with the way that you are using the query variable in the sql. If it is just that the underscore is causing problems you should try using a variable that does not rely on an underscore, inner cased variable names should work for you without problems. Run a test with the names of the variables defined without an underscore in them to see if you have the same problem. If you do then it would indicate that the problem is not with the underscores but something else. Please post back and let us know what you discover.