0
Answer

Crystal report

Surya b

Surya b

10y
902
1
How I generating a below report which contains three blocks with different records
I need the below format in crystal report 
 
Ex:
Elector Id: 123       ElectorID:254          EletorID:344
Name:Abc             Name: xyz             Name:trtr
Gender:M               Gender:M             Gender:F
Age:23                   Age:54 a               Age:34
Assembly:test       Assembly:test       Assembly:test
Parliament: aBC    Parliament::ABC    Parliament:test

I wrote the below code: 
 
private void button1_Click(object sender, EventArgs e)
{
string constr = "Data Source=.;Initial Catalog=VoterData;User ID=sa;Password=mdc@123";
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("select Voter_ID,Name,[House No],Age,Gender,Assem_constituency,Parliment_constituency,[Polling Station] from Malkajgiri", con);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\CrystalReport1.rpt";
path = path.Replace("file:\\", "");
path = path.Replace("bin\\Debug\\", "");
CrystalReport1 cr = new CrystalReport1();
doc.Load(path);
doc.SetDataSource(dt.DefaultView);
if (dt.Rows.Count == 0)
{
MessageBox.Show("No data Found", "CrystalReportWithOracle");
return;
}
else
{
crystalReportViewer1.ReportSource = doc;
crystalReportViewer1.Visible = true;
crystalReportViewer1.Refresh();
con.Close();
}
}
 
 
 
Can anybody help me in this regard?