Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
is it possible to display values from data reader to crystal report in vb.net??
my code is

VB
Imports System.Data
Imports Oracle.DataAccess.Client ' ODP.NET Oracle managed provider
Imports Oracle.DataAccess.Types


Dim oradb As String = "Data Source=orcl;User Id=hr;Password=hr;"
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "select department_name from departments where department_id = 10"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
dr.Read()
Label1.Text = dr.Item("department_name")
conn.Dispose()



here instaed of label i want to show the result set in crystal report?
I have created one crystal report and crystal report viewer.
how can i do this?
Posted
Updated 21-May-13 22:48pm
v3
Comments
Am Gayathri 22-May-13 4:48am    
Anybody please help

1 solution

You can use the following code
You can first convert the datareader to datatable

DataTable dt = new DataTable();
dt.Load(dr);

// Then you use the use that directly to the repory
ReportDocument report = new ReportDocument();
report.Load(Server.MapPath("~/Reports/bydos.rpt"));//Your report Page
report.SetDataSource(dt);
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.DataBind();

You can also refer to the following Links
http://forums.asp.net/t/1677080.aspx/1[^]
 
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