1
我想從CrystalReport中的datagridview中打印記錄。CrystalReport中的Datagridview記錄
我有以下代碼pouplate datagridview。
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\dbaza2.mdb");
DataTable dataT;
private void button1_Click(object sender, EventArgs e)
{
dataT = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand com = new OleDbCommand("SELECT * FROM Table1, Table2 WHERE Table1.SifraP = Table2.SifraM AND Table2.Mesec = @Mesec AND Table1.Fakultet = @Fakultet ORDER BY Table.Zvawe", con);
da = new OleDbDataAdapter(com);
com.Parameters.AddWithValue("@Mesec", comboBox1.Text);
com.Parameters.AddWithValue("@Fakultet", comboBox2.Text);
OleDbCommandBuilder builder = new OleDbCommandBuilder(da);
da.Fill(dataT);
this.dataGridView1.DataSource = dataT;
}
並打印水晶報表,我有以下代碼
protected PoFakultetForm izvestaj = new PoFakultetForm();
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
PoFakultetReport raporti = new PoFakultetReport();
raporti.SetDataSource(dataT);
izvestaj.reportSource(raporti);
izvestaj.Show();
}
的問題是,在DataGridView是正確填充,但在CrystalReport的數據是重複的4周時間。
如何從datagridview中將相同的數據設置爲CrystalReport?