How to open report that have sub report using other database login

59 Views Asked by At

I have a problem in my code, Discrete value dialog box asking me the customer and the insertquery but in my code I already have the values of that the strName and the strSelect.

This is my code.

Dim strSelect As String = ""
Dim report_Batch As New BILLINGRBatch
For i As Integer = 0 To dgCustomer.Rows.Count - 1
    If CBool(dgCustomer.Item(0, i).Value) = True Then

        Dim intId As Integer = dgCustomer.Item(1, i).Value
        Dim strName As String = Replace(Trim(dgCustomer.Item(2, i).Value), "'", "''")

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

        Dim dateFilter As String = ""
        If dtpFrom.Value.ToShortDateString <> dtpTo.Value.ToShortDateString Then
            dateFilter = " AND (SELECT start_date FROM bill_transaction1 WHERE transaction_id = a.transaction_id) BETWEEN ''" & dtpFrom.Value.ToShortDateString & "'' AND ''" & dtpTo.Value.ToShortDateString & "''"
        End If
        strSelect = strSelect & "insert into @t (customerid, customername,payFilter,dateFilter) select '" & intId & "','" & strName & "','" & payFilter & "','" & dateFilter & "' " & Chr(13)
    End If
Next

For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In report_Batch.Database.Tables
    Dim crTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = crTable.LogOnInfo
    Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo = crTableLogonInfo.ConnectionInfo

    crConnectionInfo.ServerName = serverName
    crConnectionInfo.DatabaseName = serverDB
    crConnectionInfo.UserID = serverUser
    crConnectionInfo.Password = serverPass

    crTable.ApplyLogOnInfo(crTableLogonInfo)
Next

report_Batch.SetParameterValue("insertquery", strSelect)

frm_printing.crp_report.ReportSource = report_Batch
frm_printing.crp_report.Zoom(100%)
frm_printing.crp_report.Refresh()
frm_printing.Show()

and also this is value of my serverName,serverUser,serverPass,serverDB. I'm using this because there is a existing database login in BILLINGRBatch and I want to change using my local values.

Dim dt As DataTable
dt = exec("SELECT value FROM settings WHERE settings = 'TENANTBILLINGSERVER' OR settings = 'TENANTBILLINGUSER' OR settings = 'TENANTBILLINGPASS' OR settings = 'TENANTBILLINGDB'")
serverName = dt.Rows(0)(0).ToString
serverUser = dt.Rows(1)(0).ToString
serverPass = dt.Rows(2)(0).ToString
serverDB = dt.Rows(3)(0).ToString

UPDATE: my BILLINGRBatch.rpt have insertquery parameter that contain customername and one of the parameter from my sub report is customername. I already link my Main report to sub report instead of displaying my crystal report its show discreate value dialog asking the value of my customername. can you help me. I'm stuck here thank you.

How to open the BILLINRRBatch and the subreport inside it without displaying the Discrete Values its automatically use the assigned values.

0

There are 0 best solutions below