Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I make a crystal report through Dynamic DataTable.
But when it bind then I get an error "a number field or currency amount field is required here". I checked datatype of datatable which I bind in crystal report fields.

See this, first I made DataTable like
C#
string type = "Gov";
            sqlSelect = "select AI_PerEntry_ID,AI_Center_Name,AI_District,AI_Date,AI_Fresh_No_Of_Bull,AI_Repeat_No_Of_Bull,AI_Male_Calf,AI_Female_Calf,AI_Type from tbl_PerformanceEntry where AI_Type='" + type + "'";
            dt = cls.FetchDataTable(sqlSelect);
            DataTable table = new DataTable("AI_Performance");
            //Creating columns
            DataColumn column = new DataColumn("id");
            DataColumn column2 = new DataColumn("Center");
            DataColumn column3 = new DataColumn("District");
            DataColumn column4 = new DataColumn("No_of_Fresh");
            DataColumn column5 = new DataColumn("No_of_Repeat");
            DataColumn column6 = new DataColumn("Totle_Insemination");
            DataColumn column7 = new DataColumn("Calf_Birth(M/F)");
            // DataColumn column8 = new DataColumn("Female_Calf");
        
            table.Columns.Add(column);
            table.Columns.Add(column2);
            table.Columns.Add(column3);
            table.Columns.Add(column4);
            table.Columns.Add(column5);
            table.Columns.Add(column6);
            table.Columns.Add(column7);
          
            for (int i = 0; i < dt.Rows.Count; i++)
            {


                int Id = Convert.ToInt32(dt.Rows[i][0]);
                string center = dt.Rows[i][1].ToString();
                string district = dt.Rows[i][2].ToString();

                int f = Convert.ToInt32(dt.Rows[i][4]);
                int r = Convert.ToInt32(dt.Rows[i][5]);
                int c = (f + r);
                if (dt.Rows[i][6] == DBNull.Value || dt.Rows[i][7] == DBNull.Value)
                {
                    MC = 0;
                    FC = 0;
                }
                else
                {
                    MC = Convert.ToInt32(dt.Rows[i][6]);
                    FC = Convert.ToInt32(dt.Rows[i][7]);
                }
               
                DataRow row = table.NewRow();
                row["id"] = Id;
                row["Center"] = center;
                row["District"] = district;
                row["No_of_Fresh"] = f;
                row["No_of_Repeat"] = r;
                row["Totle_Insemination"] = c;
                row["Calf_Birth(M/F)"] = MC + " / " + FC;
              
                table.Rows.Add(row);
               
            }
          
            AI_Performance aiperformance = new AI_Performance();
            aiperformance.dtr = table;
            aiperformance.Show();

and then bind it REPORT VIEWER "AI_Performance".
C#
////////This is my report viewer///
public DataTable dtr = new DataTable();

        public AI_Performance()
        {
            InitializeComponent();
        }

        private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
            Reports.AI_Performance crt = new Reports.AI_Performance();
           
            crt.Database.Tables[0].SetDataSource(dtr);
            crystalReportViewer1.ReportSource = crt;
            
        }
///////////

I think I have a problem in binding of datatable where some datatype problem. That's why I get that error "a number field or currency amount field is required here".

Kindly you can tell me how to solve it. I am very thankful to you.
Posted
Updated 20-Sep-12 10:23am
v3

1 solution

i solved it with another way.
i do it like this
When i was binding a data in datarow in that time i insert all value in another temp. table, from that table i bind my reportview.
simple i got my results.

Thx for all who view and reply
 
Share this answer
 

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