problem with VB.net(VS2003) and Crystal Report8

Joined
Aug 26, 2006
Messages
6
Programming Experience
3-5
hi everybody..i am working on a project that involves the use of Crystal Reports 8 along with vb.net(VS2003)..i will briefly describe in steps what i did and whre i'm stuck
1. test1.rpt was prepared with ADO connection through a dsn
2. An sql query was specified to the .rpt file
3. In the VB.Net part, i had to pass a query to the rpt file for which i did--
VB.NET:
[SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][SIZE=2] Reportapp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CRAXDRT.Application [/SIZE]
[SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][SIZE=2] Report1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CRAXDRT.Report [/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dset [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dadpt [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlDataAdapter[/SIZE]
[SIZE=2]qry = ""[/SIZE]
[SIZE=2]qry = "select a.*, b.*, c.*, d.* from store_t_preq_mast a, store_t_preq_det b, store_m_store c, store_m_item d "[/SIZE]
[SIZE=2]qry &= " where a.pur_req_code= " & StrRepl([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtpurreq.Text.Trim)[/SIZE]
[SIZE=2]qry &= " and a.pur_req_code = b.pur_req_code "[/SIZE]
[SIZE=2]qry &= " and a.store_code=c.store_code "[/SIZE]
[SIZE=2]qry &= " and b.item_code=d.item_code "[/SIZE]
[SIZE=2]rptname = ""[/SIZE]
[SIZE=2]rptname = "rpt_requisition.rpt"[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] cnn.State = ConnectionState.Closed [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]cnn.Open()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]dadpt.SelectCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand(qry, cnn)[/SIZE]
[SIZE=2]dset.Tables.Clear()[/SIZE]
[SIZE=2]dadpt.Fill(dset, "emp")[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] cnn.State = ConnectionState.Open [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]cnn.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]Report1 = Reportapp.OpenReport(Application.StartupPath & "\..\report\" & rptname, 1)[/SIZE]
[SIZE=2]Report1.Database.SetDataSource(dset.Tables("emp"))[/SIZE]
[SIZE=2]AxCRViewer2.ReportSource = Report1[/SIZE]
[SIZE=2]AxCRViewer2.ViewReport()[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] s [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = ex.Message[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]

the CRAXDRT is the Crystal Report 8 runtime library which I had to explicitly register using regsvr32

Now my problem is if i use "report1.discardsaveddata()", no data is being shown...and if i dont, the report is displaying the data according to the query specified in the rpt ADO connection, irrespective of the datatable specified in the above code. What shall I do?????
 
Back
Top