|
This has little to do with C#. You'd probably get a better/more responses on the Crystal Reports forums.
Try here[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi
I am using Crystal Report in my c# application, I have two printing options is that immediate print and preview and print. In immediate without showing the print format it directly creates hard copy. I am using the below code for achieving this
ReportClass myCrystalReport;
myCrystalReport.SetDataSource(ds);
crystalReportViewer1.ReportSource = myCrystalReport;
crystalReportViewer1.PrintReport();
My problem is that immediate print is not picking the default paper size! Its go to Letter!. But preview and print is working fine.(My paper size is A4)
And I have also try set A4 in my code
myCrystalReport.PrintOptions.PaperSize = PaperSize.PaperA4;
but I am getting same output . please help me on this issue.
Thanks in advance
Thahir
|
|
|
|
|
|
how to trace hardisk serial no,processor,ram through C#
|
|
|
|
|
Why don't you key you question into Google instead of asking simplistic question in a programming forum.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Please read http://www.codeproject.com/Messages/1278604/How-to-get-an-answer-to-your-question.aspx
|
|
|
|
|
i want to run local computer on my website
|
|
|
|
|
That question made no sense at all. Are you asking how to run a website on your local computer?? What version of Windows are you running?
|
|
|
|
|
If you mean that you want to run a website from your "home" PC - then it might not be a good idea: from a security POV it's certainly quite dangerous.
However, if you don't care about that too much, there are many guides on the internet as to how to do it. Here's one: http://www.boutell.com/newfaq/creating/hostmyown.html[^] but Google will find you loads of others.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
hi,
How to copy listbox values into gridview column
|
|
|
|
|
You could build another datasource and assign it to the grid view.
|
|
|
|
|
Loop all the values in the listbox, add them to the gridview.
..of course, that might not be a very efficient solution; depends on what's loaded in the listbox. Alternatively, you could virtualize the datagridview and fetch the values directly from the listbox.
Judging by the way the question is formulated, I think you'd be interested in this[^] book.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i have the following code that appears an error
string query_BranchExposureFactor = "SELECT BranchExposureFactor FROM Questionnaires_Table where Branch_ID = (SELECT Branch_ID FROM [MS Access;DATABASE=" + dialog.FileName + "].Questionnaires_Table1 Where ReferenceYear = '" + txtdateref.Text + "');";
OleDbCommand cmd_BranchExposureFactor = new OleDbCommand(query_BranchExposureFactor, dbConnDest);
double branchExposureFactor = ((double)cmd_BranchExposureFactor.ExecuteScalar());
the error is :
----------------
Object reference not set to an instance of an object.
|
|
|
|
|
The stack trace would tell you exactly what line.
zebra88 wrote: ExecuteScalar
That can return null.
|
|
|
|
|
double branchExposureFactor = ((double)cmd_BranchExposureFactor.ExecuteScalar());
the error is in above row but i didn't know what is the solution for this error :
Object reference not set to an instance of an object.
|
|
|
|
|
Have you verified that your query string returns the appropiate data?
Does
zebra88 wrote: dialog.FileName and
zebra88 wrote: txtdateref.Text have appropiate values?
Sounds to me that ExecuteScalar is returning null.
According to the MSDN documentation[^] on the OleDbCommand:
Return Value
Type: System.Object
The first column of the first row in the result set, or a null reference if the result set is empty.
Check if it is indeed returning null, if it is, check your input.
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
the user must input to the form a reference year and must choose an access file that the program have to take some record from this file with this reference year and add to another access file with insert query but sometimes maybe the user choose a year that does not be in access file.
How can i verify that when the query has return null will must return a message to the user that the year that has enter does not exist in access file ??
yes dialog.FileName and txtdateref.Text has the appropriate values.
|
|
|
|
|
For starters, you should validate the values both in the FileDialog and the TextBox (check that the file exists and check the textbox's text is actually a number, at the very least) then after building your query and preparing your command, store the result from ExecuteScalar in an object variable, then check that for null, if it is null, present an error message, if its not, then cast it to whatever its type should be.
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
thanks i solve my c# problem
|
|
|
|
|
string query_BranchExposureFactor = "SELECT BranchExposureFactor FROM Questionnaires_Table where Branch_ID = (SELECT Branch_ID FROM [MS Access;DATABASE=" + dialog.FileName + "].Questionnaires_Table1 Where ReferenceYear = '" + txtdateref.Text + "');";
OleDbCommand cmd_BranchExposureFactor = new OleDbCommand(query_BranchExposureFactor, dbConnDest);
double branchExposureFactor = (double.TryParse()) (cmd_BranchExposureFactor.ExecuteScalar().ToString());
i have error to the following code
double branchExposureFactor = (double.TryParse()) (cmd_BranchExposureFactor.ExecuteScalar().ToString());
|
|
|
|
|
The error is when you try and convert the return to a double, the return may be null. Change the return object (currently branchExposureFactor) to an object type and test it for null before trying to convert it to double.
double.TryParse would have caught the error.
Always test for null when using any object.
Do a little research on "Little Bobby Tables" otherwise he will trash you database!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If the rest of your application is written in a similar manner you are heading for serious trouble. Your SQL is wide open to injection attacks, you are not checking the user's input values and you are ignoring the possibility that any command could fail. You should rewrite the above to do the following:
- Check the content of the textboxes to see that they contain valid data.
- Use proper parameterised SQL queries.
- Split your SQL query into two parts so you first find whether the
BranchID query returns a good result. - Using the value returned from the
BranchID query, check the return value of the second query for the BranchExposureFactor . - Use the
double.TryParse() method to check that you have a valid floating point value.
Use the best guess
|
|
|
|
|
OleDbConnection dbConnDest;
dbConnDest = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= SystemA.accdb");
string query_select = "SELECT ReferenceYear FROM [MS Access;DATABASE=" + dialog.FileName + "].Questionnaires_Table1 Where ReferenceYear = '" + txtdateref.Text + "';";
OleDbCommand cmd_year = new OleDbCommand(query_select, dbConnDest);
dbConnDest.Open();
string rfyear = cmd_year.ExecuteScalar().ToString();
if (rfyear == null) { MessageBox.Show(" file not found with this ref year ", "", MessageBoxButtons.OK); }
dbConnDest.Close();
i have error in following row
string rfyear = cmd_year.ExecuteScalar().ToString();
if the query is wrong appears the error:
------------------------------------------
Object reference not set to an instance of an object.
|
|
|
|
|
zebra88 wrote: Object reference not set to an instance of an object.
And that is exactly the same cause/reason as your original problem.
|
|
|
|
|
zebra88 wrote: string rfyear = cmd_year.ExecuteScalar().ToString(); The line contains multiple statements.
object result = cmd_year.ExecuteScalar();
if (DBNull.Value == result || null == result)
throw new ApplicationException("Panic Now!");
string rf_year = Convert.ToString(result); Put a breakpoint on the first line (place the cursor there and press F9), step trough the code (Hit F5 to run, hit F11 to step once you hit the breakpoint). On the second line of this example, examine the value of the result -variable by hovering your mouse above it in the IDE.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|