Click here to Skip to main content
15,884,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a project in C# .Net. I am new to C# as well as Crystal reports.
I have made a form having "View" button and some combo Boxes, date time picker on it.
On clicking the View button, I want a new form to open having only crystal report viewer on it.
So, I made a new form by adding new item->Windows Form.

C#
CrystalReportViewer crystalReportViewer1;
CrystalReport1 objRpt;
Ds = new DataSet1();
cnn = new OleDbConnection(connString);
OleDbCommand command = new OleDbCommand(query, cnn);
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
cnn.Open();
command.Parameters.Add("?", OleDbType.VarChar).Value = date_from;
command.Parameters.Add("?", OleDbType.VarChar).Value = date_to;
adapter.Fill(Ds, "DataTable1");
objRpt.SetDataSource(Ds);
crystalReportViewer1.ReportSource = objRpt; --> Error


But when I try to access crystalReportViewer on form1, it gives error since it is from form2.
If I want to access variables from form1 on form2, what should be done?
So, can anybody help me to solve this problem?
Posted
Updated 6-Feb-13 18:39pm
v3
Comments
veenusethi 7-Feb-13 4:05am    
try to use sessions and pass them from form1 to form2
thatraja 31-Oct-13 6:51am    
what's the error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900