I have problem with printing Crystalreports from Dataset as a source.
I have a Dataset fullfilled with data from query and CrystalRaports doesn't show
any data from dataset on the report.
Do you haeve any ideas what is the problem.
My Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
namespace PV_Report
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string sql = "select c782_storenr,c782_date,c782_pricefrom,c782_priceto,c782_moduser,c782_moddate from t782 "
+"where c782_storenr between 1000 and 9000 "
+"and c782_date = to_date('2010-06-30','yyyy-mm-dd') "
+"order by c782_moddate, c782_storenr";
string connsetting = "Data Source=xxxx;User Id=xxxx;Password=xxxx;";
Daneset queryResult = new Daneset();
OracleConnection connection = new OracleConnection(connsetting);
connection.Open();
OracleCommand command = new OracleCommand(sql, connection);
command.CommandText = sql;
OracleDataAdapter adapter = new OracleDataAdapter();
adapter.SelectCommand = command;
adapter.Fill(queryResult,"tabledata");
connection.Close();
int temp = queryResult.Tables["tabledata"].Rows.Count;
for (int i = 0; i < queryResult.Tables["tabledata"].Rows.Count; i++)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = queryResult.Tables["tabledata"].Rows[i].ItemArray[0];
dataGridView1.Rows[i].Cells[1].Value = queryResult.Tables["tabledata"].Rows[i].ItemArray[1];
dataGridView1.Rows[i].Cells[2].Value = queryResult.Tables["tabledata"].Rows[i].ItemArray[2];
dataGridView1.Rows[i].Cells[3].Value = queryResult.Tables["tabledata"].Rows[i].ItemArray[3];
dataGridView1.Rows[i].Cells[4].Value = queryResult.Tables["tabledata"].Rows[i].ItemArray[4];
dataGridView1.Rows[i].Cells[5].Value = queryResult.Tables["tabledata"].Rows[i].ItemArray[5];
}
CrystalReport1 cr = new CrystalReport1();
cr.SetDataSource(queryResult.Tables["tabledata"]);
cr.Refresh();
crystalReportViewer1.ReportSource = cr;
crystalReportViewer1.Refresh();
}
}
}