Rdlc报告未显示第一条记录 [英] Rdlc report does not show first record
本文介绍了Rdlc报告未显示第一条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我在C#中使用rdlc报告。我在表格中有一个表格项目显示所有
记录,但它显示除第一条记录外的所有记录。
任何人都可以帮助我吗?
这是我的代码
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 *来自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();
}
解决方案
我使用以下代码在表格中保存了datagridview行:
for ( int i = 0 ; i < dataGridView1.Rows.Count; i ++)
{
OleDbConnection conn;
OleDbCommand cmd;
string connectionstring = Provider = Microsoft。 ACE.OLEDB.12.0;数据源= | 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,@ MalatTotal,@ TotalKosour,@ VighehPardakhti);,conn);
cmd.Parameters.AddWithValue( @ RowNumber,dataGridView1.Rows [i] .Cells [ 0 ]。值);
cmd.Parameters.AddWithValue( @ CMonth,lblMonth.Text.Trim() );
cmd.Parameters.AddWithValue( @ Shahrestan,lblShahrestan.Text.Trim() );
cmd.Parameters.AddWithValue( @ ComputerCode,dataGridView1.Rows [i]。单元格[ 1 ]。值);
cmd.Parameters.AddWithValue( @ ShomarehHesab,dataGridView1.Rows [i]。单元格[ 2 ]。值);
cmd.Parameters.AddWithValue( @ CName,dataGridView1.Rows [i]。单元格[ 3 ]。值);
cmd.Parameters.AddWithValue( @ FixSalary,dataGridView1.Rows [i]。单元格[ 4 ]。值);
cmd.Parameters.AddWithValue( @ BimehEjtemaeiBist,dataGridView1.Rows [i]。单元格[ 5 ]。值);
cmd.Parameters.AddWithValue( @ GhabelHazineh,dataGridView1.Rows [i]。单元格[ 6 ]。值);
cmd.Parameters.AddWithValue( @ BimehEjtemaeiHaft,dataGridView1.Rows [i]。单元格[ 7 ]。值);
cmd.Parameters.AddWithValue( @ MaliatTotal,dataGridView1.Rows [i]。单元格[ 8 ]。值);
cmd.Parameters.AddWithValue( @ TotalKosour,dataGridView1.Rows [i]。单元格[ 9 ]。值);
cmd.Parameters.AddWithValue( @ VighehPardakhti,dataGridView1.Rows [i]。单元格[ 10 ]。值);
尝试
{
conn.Open();
cmd.CommandType = CommandType.Text;
cmd.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult);
}
catch
{
MessageBox .Show( ایرادیدرعملیاتوجوددارد);
}
最后
{
cmd.Dispose() ;
// conn.Close();
// conn.Dispose();
}
}
然后我将此表发送到reportviewer.when我使用断点检查数据网格行正确保存在表中的代码但是当我删除断点时它没有正确保存。 / BLOCKQUOTE>
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
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(); }解决方案I save rows of datagridview in a table with this code:
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.
这篇关于Rdlc报告未显示第一条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文