|A couple of things unrelated to your question:
1) Never use Convert methods on user input: users mistype, and Convert will throw an exception on errors. Always check user input using the TryParse method instead:
if (!int.TryParse(textBox4.text, out fact))
... report input problem to user ...
2) Do yourself a favour, and stop using Visual Studio default names for everything - you may remember that "TextBox8" is the mobile number today, but when you have to modify it in three weeks time, will you then? Use descriptive names - "tbMobileNo" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbMobile" in three keystrokes, where "TextBox8" takes thinking about and 8 keystrokes...
3) Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.
When you concatenate strings, you cause problems because SQL receives commands like:
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;Which SQL sees as three separate commands:
SELECT * FROM MyTable WHERE StreetAddress = 'x';A perfectly valid SELECT
DROP TABLE MyTable;A perfectly valid "delete the table" command
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.
So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?
OK, in this example it wouldn't cause a problem, but you need to check every single other access in your application - miss one, and you are at risk. It's a very,. very good idea to get into the habit or always using parameterized queries, even when you don't have to - that way future changes are safer.
4) SqlConnections, SqlCommands, and so forth are scarce resources: you should ensure that they are Disposed when you are finished with them - the best way is to just use a
using block for each constructor - the object will be disposed automatically when it goes out of scope.
As far as your actual question goes, we can't help based on the code you show: it doesn't display the report at all, just set up some conditions for it to be displayed or printed. You need to look elsewhere in your code to find out exactly what happens from that point.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.