Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I use rdlc report in C# . I have a Table Item in the form to show all
record but it show all record except first record .
Can any one help me ?

this is my code
C#
private void DocReportOnlyFixSalaryView_Load(object sender, EventArgs e)
{

    OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|" + "\\DB\\" + Class.Global.CurrentYear);
    OleDbDataAdapter da = new OleDbDataAdapter("SELECT * from DocReportFixSalaryJoda", con);

    DataSet ds = new DataSet();

    da.Fill(ds);

    ds.Tables[0].TableName = "DataTableDocReportFixSalaryJoda";



    reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", ds.Tables[0]));
     da.Dispose();
      con.Close();

    this.reportViewer1.RefreshReport();
}
Posted
Comments
ArunRajendra 8-Apr-14 1:05am    
Its difficult to give the solution. You have to put break point and find out where the record is getting lost. Then we can try to help.

1 solution

I save rows of datagridview in a table with this code:
C#
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
    OleDbConnection conn;
    OleDbCommand cmd;
    string connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|" + "\\DB\\" + Class.Global.CurrentYear;
    conn = new OleDbConnection(connectionstring);
    cmd = conn.CreateCommand();

    cmd = new OleDbCommand("INSERT INTO DocReportFixSalaryJoda (RowNumber,CMonth,Shahrestan,ComputerCode,ShomarehHesab, CName, FixSalary, BimehEjtemaeiBist, GhabelHazineh, BimehEjtemaeiHaft, MaliatTotal, TotalKosour,VighehPardakhti) VALUES (@RowNumber,@CMonth,@Shahrestan,@ComputerCode,@ShomarehHesab, @CName, @FixSalary, @BimehEjtemaeiBist,@GhabelHazineh, @BimehEjtemaeiHaft, @MaliatTotal, @TotalKosour,@VighehPardakhti);", conn);

    cmd.Parameters.AddWithValue("@RowNumber", dataGridView1.Rows[i].Cells[0].Value);
    cmd.Parameters.AddWithValue("@CMonth", lblMonth.Text.Trim());
    cmd.Parameters.AddWithValue("@Shahrestan", lblShahrestan.Text.Trim());
    cmd.Parameters.AddWithValue("@ComputerCode", dataGridView1.Rows[i].Cells[1].Value);
    cmd.Parameters.AddWithValue("@ShomarehHesab", dataGridView1.Rows[i].Cells[2].Value);
    cmd.Parameters.AddWithValue("@CName", dataGridView1.Rows[i].Cells[3].Value);
    cmd.Parameters.AddWithValue("@FixSalary", dataGridView1.Rows[i].Cells[4].Value);
    cmd.Parameters.AddWithValue("@BimehEjtemaeiBist", dataGridView1.Rows[i].Cells[5].Value);
    cmd.Parameters.AddWithValue("@GhabelHazineh", dataGridView1.Rows[i].Cells[6].Value);
    cmd.Parameters.AddWithValue("@BimehEjtemaeiHaft", dataGridView1.Rows[i].Cells[7].Value);
    cmd.Parameters.AddWithValue("@MaliatTotal", dataGridView1.Rows[i].Cells[8].Value);
    cmd.Parameters.AddWithValue("@TotalKosour", dataGridView1.Rows[i].Cells[9].Value);
    cmd.Parameters.AddWithValue("@VighehPardakhti", dataGridView1.Rows[i].Cells[10].Value);

    try
    {
        conn.Open();
        cmd.CommandType = CommandType.Text;
        cmd.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult);



    }
    catch
    {

        MessageBox.Show("ایرادی در عملیات وجود دارد");


    }

    finally
    {
        cmd.Dispose();
        //  conn.Close();
        //conn.Dispose();
    }

}

then I send this table to reportviewer.when i use break point to check code the row of datagrid has saved in table correctly but when i remove break point it not saved correctly.
 
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