Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,

my code does not working properly.i searched for this problem very and i do not know where is the problem.

this is my code

CrystalReport2 objRpt = new CrystalReport2();
            SqlConnection cnn;
            string connectionString = null;
            string sql = textBox1.Text;
            connectionString="server=localhostDatabase=AhmadfamDatabaseTrusted_Connection=true";
            cnn = new SqlConnection(connectionString);
            cnn.Open();
            SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
            DataSet1 ds = new DataSet1();
            dscmd.Fill(ds, "OmdeSell_Table");
            MessageBox.Show(ds.Tables[1].Rows.Count.ToString());
            objRpt.SetDataSource(ds.Tables[1]);
            
            crystalReportViewer1.ReportSource = objRpt;
            crystalReportViewer1.Refresh();


in the messagebox i can see rows count for example 320 but crystalreportviewer1 does not show any information. i added a property to the app.config file startup tag that is:
useLegacyV2RuntimeActivationPolicy="true"
when i remove this property an error occor that is
C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll


i do not know what to do to solve this problem.i am confused. please help me.
Posted
Updated 18-Apr-14 10:35am
v2
Comments
Kschuler 18-Apr-14 17:15pm    
If your report doesn't error out but isn't showing what you expect it to, I'd start with making sure it's setup properly. Is everything properly linked in the Database Expert of your Crystal Report? Are you doing anything special in the report like sub reports or graphs or anything?
_Starbug_ 18-Apr-14 17:31pm    
first i added a crystal report to my project. then i select using wizard option for it then i select dataset1 as dataset from my project data(dataset has a datatable with 12 column) for it. and i do not added any information about sub report of group for it.

i added dataset1 for it. when i execute the code in the messagebox count of rows for my query are shown for example 320.
Mahesh@Dev 18-Apr-14 21:18pm    
Your Sql query Missing Here...Write Your Full extracted Query For Get Record
_Starbug_ 19-Apr-14 4:41am    
full extracted query?what is it? and where i must write it?

1 solution

CrystalReport2 objRpt = new CrystalReport2();
SqlConnection cnn;
string connectionString = null;
string sql = "Select * from OmdeSell_Table where Id="+textBox1.text+"";
connectionString="server=localhostDatabase=AhmadfamDatabaseTrusted_Connection=true";
cnn = new SqlConnection(connectionString);
cnn.Open();
SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
DataSet1 ds = new DataSet1();
dscmd.Fill(ds, "OmdeSell_Table");
MessageBox.Show(ds.Tables[1].Rows.Count.ToString());
objRpt.SetDataSource(ds.Tables[1]);

crystalReportViewer1.ReportSource = objRpt;
crystalReportViewer1.Refresh();
 
Share this answer
 
v2
Comments
_Starbug_ 19-Apr-14 3:07am    
i tested this but it is not answering. when i use "select * from OmdeSell_Table" that must answer.i think the problem is not from query. i think every thing is correct until line 12.because in line 11 message box show us number of rows affected. i think the problem is with crystal report or crystal report viewer.
Mahesh@Dev 22-Apr-14 10:32am    
what is the error Please Maintain Here.

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