PDA

Click to See Complete Forum and Search --> : [RESOLVED] Passing 'values' to generate reports


rockadudele
Mar 2nd, 2006, 01:14 AM
Hi
I'd like to generate reports based on values that the user is able to input. I need to generate reports during runtime. Tried most methods but not able to make it work.

I'm using an MS access Database, VB .net 2002, Crystal reports for .NET

below is the code that i've tried working with.

What I get is a dialog box which requests for UserName and password which i dont want displayed. How could I avoid that?

Please help.

:confused: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OleCon.Close()
Dim ADOcon As New ADODB.Connection()

ADOcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\REPORTS_DB\TEST_CRY_0016.mdb;Jet OLEDB:Database Password=prax;"
OleCon.ConnectionString = ADOcon.ConnectionString

Dim repDA As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM testinfo WHERE testscore > 50", OleCon)
Dim MyCmdBuilderDT_rep As New System.Data.OleDb.OleDbCommandBuilder(repDA)

repDA.Fill(repDS)
DataGrid1.DataSource = repDS.Tables(1)
MsgBox("pause")

rptCrewRecord.Load("..\CrystalReport2.rpt")
rptCrewRecord.SetDataSource(repDS)

Dim viewReport As New ReportView()
'Set the Parent Form of the Child window.

'Display the new

viewReport.ShowDialog()


End Sub

rockadudele
Mar 6th, 2006, 03:51 AM
Solved this one myself, but with a little help from looking at codes posted on this forum, and here I am posting the code in case it might be of some help to someone who comes by here.


Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim Appl As New CRAXDDRT20.Application()
Dim ADOcon As New ADODB.Connection()


Dim App As New Scripting.FileSystemObject()
Dim fso As New FileSystemObject()

Dim Conn As Connection
Dim strSQL As String
Dim Rs As ADODB.Recordset

Dim crewidSel As String = crewidX.SelectedValue

Conn = New Connection()

ADOcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\REPORTS_DB\TEST_CRY_0016.mdb;Jet OLEDB: Database Password=prax;"
'OleCon.ConnectionString = ADOcon.ConnectionString


ADOcon.Open()

' MsgBox("crewidx.sel is " & crewidSel)

' crewidSel is the variable that i get from the form and create a
' RecordSet and finally view the recordset using Crystal Report view.


strSQL = "SELECT * FROM testinfo WHERE crewid = '" & crewidSel & "'"



Rs = New ADODB.Recordset()
Rs = ADOcon.Execute(strSQL)
Appl = New CRAXDDRT20.Application()

rptCrewRecord.Load("..\CrystalReport2.rpt")
rptCrewRecord.SetDataSource(Rs)


Dim viewReport As New ReportView()


viewReport.ShowDialog()

rptCrewRecord.Close()

End Sub

KGComputers
Mar 6th, 2006, 07:42 PM
Great!!!!!

One thing, can you put vb code tags in your code so it will be more readable...
Thanks.....

:) :) :)