Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I'm new in VB.NET and I want to pass the value from to crystal report. I have a problem that the "Enter Parameter Value" keep asking a value even in my code there's already a value.

When I remove this code I know "Enter Parameter Value" will prompt asking the insertquery and customer, but what happened is it's asking insertquery,customer,insertquery. IDK why insertquery again ask the values of the parameter.

report_Batch.SetParameterValue("insertquery", strSelect)
report_Batch.SetParameterValue("customer", strName)

can anyone help me why this "Enter Parameter value" dialog asking again the insertquery. Thanks

What I have tried:

Here's my code.

Dim report_Batch As New BILLINGRBatch 'my crystal report
Dim strName As String = ""
Dim intId As Integer
Dim payFilter As String = ""
Dim dateFilter As String = ""
Dim strSelect As String = ""
For i As Integer = 0 To dgCustomer.Rows.Count - 1
    If CBool(dgCustomer.Item(0, i).Value) = True Then
        intId = dgCustomer.Item(1, i).Value
        strName = Replace(Trim(dgCustomer.Item(2, i).Value), "'", "''")

        If txtPayId.Text <> 0 Then
            payFilter = " AND a.status = '" & txtPayId.Text & "'"
        End If

        If dtpFrom.Value <> dtpTo.Value Then
            dateFilter = " AND (SELECT start_date FROM bill_transaction1 WHERE transaction_id = a.transaction_id) BETWEEN ''" & dtpFrom.Value.ToString("yyyy-MM-dd") & "'' AND ''" & dtpTo.Value.ToString("yyyy-MM-dd") & "''"
        End If
        strSelect &= "insert into @t (selected, customername,payFilter,dateFilter) select '" & intId & "','" & strName & "','" & payFilter & "','" & dateFilter & "' " & Chr(13)
    End If

For Each table As CrystalDecisions.CrystalReports.Engine.Table In report_Batch.Database.Tables
    Dim logonInfo As CrystalDecisions.Shared.TableLogOnInfo = table.LogOnInfo
    logonInfo.ConnectionInfo.ServerName = serverName
    logonInfo.ConnectionInfo.DatabaseName = serverDB
    logonInfo.ConnectionInfo.UserID = serverUser
    logonInfo.ConnectionInfo.Password = serverPass

For Each subReport As ReportDocument In report_Batch.Subreports
    For Each Table As Table In subReport.Database.Tables
        Dim logonInfo As CrystalDecisions.Shared.TableLogOnInfo = Table.LogOnInfo
        logonInfo.ConnectionInfo.ServerName = serverName
        logonInfo.ConnectionInfo.DatabaseName = serverDB
        logonInfo.ConnectionInfo.UserID = serverUser
        logonInfo.ConnectionInfo.Password = serverPass

report_Batch.SetParameterValue("insertquery", strSelect)
report_Batch.SetParameterValue("customer", strName)

frm_printing.crp_report.ReportSource = report_Batch
Updated 25-Jul-23 14:08pm
Raf-Reyes 25-Jul-23 22:45pm    
Okay let me rephrase my question. I have a Main report(BILLINGRBatch.rpt) that have a table with column selected,customername,payFilter,dateFilter and the value of that comes from the parameter insertquery.
Now in my sub report(BILLINGR.rpt) I have a parameter selected,customer,dateFilter,payFilter I already link this parameter to the columns in Main report.
My problem is there's no displaying values in my sub report but when in main report I can see the values of my insertquery its displaying. Do you think I my sub report is not connected to main report? but I already linked it.
And my other problem is "Enter parameter value" dialog showing and asking insertquery value, but I have a value and its display in my Main report.? sorry if my english is bad hope you undestand what I'm trying to say. Thanks

1 solution

None of that code sets anything in report_Batch other than the two parameters. So at a guess, the command string (which we can't see) that the report is based on contains parameters you aren't setting.

Use the debugger: find out exactly what report_Batch is set up to do at the point where you set the parameter values. Either the names are wrong, or the command is not the one you think it is.
Share this answer
Dave Kreskowiak 25-Jul-23 9:16am    
What?? Nothing on the SQL query string concatenation? You're falling down on the job man!
OriginalGriff 25-Jul-23 9:43am    
Raf-Reyes 25-Jul-23 21:04pm    
I think my problem is in the setParametervalue of my insertquery. my strSelect have a value but when I put to SetParameterValue I think no value is setting? thats why its crystal report is asking a value. idk how to pass the value of strSelect to parameter insertquery in crystal report.
Raf-Reyes 25-Jul-23 20:14pm    
hello, sorry I forgot to put the report_Batch as my Crystal report. setting may parameters is incorrect? @OriginalGriff

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