VB.NET - regarding windows form and crystal report

Asked By sadhish babu muthusamy on 27-Jun-12 08:48 PM
Earn up to 20 extra points for answering this tough question.
hi all,

good day,


i want export the vb window form to crystal report................................

in the window form contain textbox, label, checkbox,

i want all the control in the form should display in the crystal report....


Thanks in advance..
Jitendra Faye replied to sadhish babu muthusamy on 29-Jun-12 12:22 AM
You can not export Windows form to Crystal report but you can display control data in crystal report.

means after getting values from controls you can show these value to crystal report.
 

sadhish babu muthusamy replied to Jitendra Faye on 29-Jun-12 02:10 AM

Hi,

Thanks for reply Vickey F.

ok..........then how i can do that.....

Jitendra Faye replied to sadhish babu muthusamy on 29-Jun-12 03:00 AM
Get all the values of controls and put in one DataTable,

after filling datatable with data assign it to  crystal  report .

Like this-

DataTable dt = new DataTable();
dt.Columns.Add("col1");
dt.Columns.Add("col1");

DataRow r = dt.NewRow();

r[0] = lbl.Text;
r[1] = txt.Text;
dt.Rows.Add(r);

//Now assign this dt to crystal report as datasource.

ReportDocument RptDoc = new ReportDocument();
 
    RptDoc.Load(Server.MapPath("~/CrystalReport.rpt"));
    RptDoc.SetDataSource(dt);
 
    CrystalReportViewer1.ReportSource = RptDoc;
    CrystalReportViewer1.DataBind();   


Try this and let me know.



sadhish babu muthusamy replied to Jitendra Faye on 29-Jun-12 10:11 AM

hi Vickey F,


i convert the code which given earlier from C# to vb.net

but i receive error in some lines and how i can the dataset in crystal reportviewer......

Dim dt As New DataTable()
dt.Columns.Add("col1")
dt.Columns.Add("col1")

Dim r As DataRow = dt.NewRow()

r(0) = lbl.Text
r(1) = txt.Text
dt.Rows.Add(r)

'Now assign this dt to crystal report as datasource.

Dim RptDoc As New ReportDocument()

RptDoc.Load(Server.MapPath("~/CrystalReport.rpt"))   \\i receive error on the syntax Server
RptDoc.SetDataSource(dt)

CrystalReportViewer1.ReportSource = RptDoc
CrystalReportViewer1.DataBind()    \i receive error on the syntax .databind

how i can call the dataset in the crystal report under database field ........