VB 6.0 - Crystal report problem help me please?

Asked By Ralph Acido on 03-Mar-06 03:56 AM
hello! is it possible to create a crystal report with no connections, tables at all??.. i mean you are going to set the datasource including the connection during run time... let say for example i have an SQL statement like this:

strsql = "Select idnum, lname, fname, mname, grade_level, section from tblstudents"
strsql = strsql & " where grade_level = 'I'"


how can i pass this SQL statement to a crystal report so that it would display the data that meets the criteria?? please help... thank you?

crystal - Asked By Shallu Gupta on 03-Mar-06 04:15 AM

Hi,
It would be better to bind the Report with stored procedure instead of a query. 
create a parameterized stored procedure . and you can pass the parameter as
[CODE]
Private Sub Process1()
         Dim param1Fileds As New CrystalDecisions.Shared.ParameterFields()
       Dim param1Field As New CrystalDecisions.Shared.ParameterField()
       Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue()
       Dim Report1 As New CrystalReport2()

       param1Field.ParameterFieldName = "GradeLevel" 
       param1Range.Value = txtGrade.Text    'asssign value to the parameter
       param1Field.CurrentValues.Add(param1Range)
       param1Fileds.Add(param1Field)                   ' To add parameter in parameterslist
       CrystalReportViewer1.ParameterFieldInfo = param1Fileds 
       CrystalReportViewer1.ReportSource = Report1            
       CrystalReportViewer1.Refresh()

   End Sub
[/CODE]